Friday, March 29, 2013

method aliasing

It's possible to create aliases for methods in Ruby:

Now we can call either say_hello or greet and have the same results:

> h = Hello.new
=> #<Hello:0x9390ba8>

> h.say_hello

Hello!
=> nil

> h.greet

Hello!
=> nil

No comments:

Post a Comment