Created
December 29, 2010 16:07
-
-
Save Ejhfast/758674 to your computer and use it in GitHub Desktop.
Ruby send usage
This file contains 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
# This is what we did | |
self.class.send :define_method, symbol, &block | |
# This, although seemingly equivalent, would not work | |
# because define_method is private | |
define_method symbol, &block | |
# Another example of using send | |
[1,2,3].first # is equivalent to | |
[1,2,3].send(:first) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment