[ruby-core:32932] Behavior of initialize in 1.9

From: Aaron Patterson <aaron@...>
Date: 2010-10-28 11:12:42 UTC
List: ruby-core #32932
The behavior of initialize in 1.9 seems to have changed.  Here is an irb
sample from 1.8 and 1.9 to illustrate the difference:

>> RUBY_VERSION
=3D> "1.8.7"
>> class Foo; end
=3D> nil
>> Foo.new(:a)
ArgumentError: wrong number of arguments (1 for 0)
        from (irb):3:in `initialize'
        from (irb):3:in `new'
        from (irb):3
>>

irb(main):001:0> RUBY_VERSION
=3D> "1.9.3"
irb(main):002:0> class Foo; end
=3D> nil
irb(main):003:0> Foo.new(:a)
=3D> #<Foo:0x0000010102c2c0>
irb(main):004:0>

Is this change intentional?  If so, why?  If you're testing first during
development, this behavior seems surprising to me.

--=20
Aaron Patterson
http://tenderlovemaking.com/

In This Thread

Prev Next