[LRUG] Ruby functions

Simon Sebright simonsebright at hotmail.com
Thu Oct 29 00:15:49 PDT 2009


Hi folks,

I gave an informal Ruby talk yesterday to some teammates and we did a bit of hands-on stuff.  A couple of things arose which I couldn't explain; I wonder if someone on this list might be able to answer.

First, in irb, we reopened the Fixnum class and added a method double.  Then we successfully called 5.double.  Then we looked at 5.methods and it wasn't there.  Why is that?  A feature of irb, or is there something more subtle going on?

Secondly someone asked if functions were first-class objects and if you can for example get the code for a function.  I rather think the ruby way is to use blocks as a way to get functions called back.  Or maybe to turn them into a proc object?

Thanks for any advice,
Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20091029/a38b6d39/attachment-0003.html>


More information about the Chat mailing list