Created
October 14, 2010 16:22
-
-
Save dchelimsky/626494 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby-1.9.2-p0 > class Foo; end | |
#=> nil | |
ruby-1.9.2-p0 > Foo.new('bar') | |
#=> #<Foo:0x00000100974e50> | |
ruby-1.9.2-p0 > class Foo; end | |
=> nil | |
ruby-1.9.2-p0 > Foo.new(1,2) | |
=> #<Foo:0x000001009dd4a0> | |
ruby-1.9.2-p0 > Foo.new(1,2,3, :a => 'b') | |
=> #<Foo:0x0000010181b918> | |
ruby-1.9.2-p0 > class Foo; def initialize; end; end | |
=> nil | |
ruby-1.9.2-p0 > Foo.new(1,2,3, :a => 'b') | |
ArgumentError: wrong number of arguments (4 for 0) | |
from (irb):5:in `initialize' | |
from (irb):6:in `new' | |
from (irb):6 | |
from /Users/david/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>' |
So what do you think should be the arity on Object#new?
0, as it is in ruby-1.8.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem, btw, is that the earlier examples allow you to pass in args that are unexpected - not that the last example raises an error (that's what should happen in the earlier examples, in my view).