A
artbot
hi,
all the time i thought [] would be a shortcut for the corresponding
class method of the class Array, but after
def Array.[](*args)
puts "blah"
end
i still get
a= [1, 2, 3]
=> [1, 2, 3]
and on the other hand
a= Array[1, 2, 3] # or a= Array.[](1, 2, 3)
blah
=> nil
so what is the exact cause of the difference?
can I somehow redefine the 'global' []
all the time i thought [] would be a shortcut for the corresponding
class method of the class Array, but after
def Array.[](*args)
puts "blah"
end
i still get
a= [1, 2, 3]
=> [1, 2, 3]
and on the other hand
a= Array[1, 2, 3] # or a= Array.[](1, 2, 3)
blah
=> nil
so what is the exact cause of the difference?
can I somehow redefine the 'global' []