Hi,
Sorry if the following is such a n00b question.
But I just don't get 1 thing.
What is the difference between
a = Array.new
and
a = []
Look at the following code:
class Class
alias oldNew new
def new(*args)
puts 'Creating new ' + self.to_s
oldNew(*args)
end
end
class Array
alias oldInit initialize
def initialize(*args)
puts 'Initializing Array'
oldInit(*args)
end
end
# this works as expected
a = Array.new
# this doesn't work
b = [1,2,3,4]
How is the Array constructed when using literals as in `a = []` ? Why
hasn't the overriding of those 2 methods worked ?