From: Matt Mongeau Date: 2013-03-20T16:12:06+09:00 Subject: Re: Confusion with has object creation. --bcaec54d3f8472538604d855f0bd Content-Type: text/plain; charset=ISO-8859-1 This is the method http://www.ruby-doc.org/core-2.0/Hash.html#method-c-5B-5D You can indeed overwrite it: irb(main):001:0> class Hash irb(main):002:1> def self.[](*args) irb(main):003:2> {} irb(main):004:2> end irb(main):005:1> end => nil irb(main):006:0> Hash['1','2'] => {} On Wed, Mar 20, 2013 at 12:01 AM, Hans Mackowiak wrote: > Hash[] only call methods that you can not overwrite... it allocates the > Hash without calling initialize. > > Hash[obj] with only one argument does some kind of Magic too (because it > trys to convert into an Hash and if that fails, try to convert into > Array) > > -- > Posted via http://www.ruby-forum.com/. > > --bcaec54d3f8472538604d855f0bd Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
This is the method

http://www.ruby-doc.org/c= ore-2.0/Hash.html#method-c-5B-5D

You= can indeed overwrite it:

irb(main):001:0> class Hash
irb(main):002:1> def self.[](*args)
irb(main):003:2> {}<= /div>
irb(main):004:2> end
irb(main):005:1> end
=3D> nil
irb(main):006:0> Hash['1','2'= ]
=3D> {}


=
On Wed, Mar 20, 2013 at 12:01 AM, Hans Mackowiak= <lists@ruby-forum.com> wrote:
Hash[] only call methods that you can not ov= erwrite... it allocates the
Hash without calling initialize.

Hash[obj] with only one argument does some kind of Magic too (because it trys to convert into an Hash and if that fails, try to convert into
Array)

--bcaec54d3f8472538604d855f0bd--