Skip to content

Instantly share code, notes, and snippets.

@sikachu
Created February 19, 2013 00:54
Show Gist options
  • Save sikachu/4982127 to your computer and use it in GitHub Desktop.
Save sikachu/4982127 to your computer and use it in GitHub Desktop.
calling object's method in method definition in Ruby
irb(main):001:0> class Foo
irb(main):002:1> def initialize(a, b = a.to_s)
irb(main):003:2> puts [a, b].inspect
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> Foo.new 1
[1, "1"]
=> #<Foo:0x007f973d9ca410>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment