Created
August 21, 2013 19:33
-
-
Save cowboyd/6299096 to your computer and use it in GitHub Desktop.
I did not know that.
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
[1] pry(main)> Class.new.respond_to?(:define_method) | |
=> false | |
[2] pry(main)> Module.new.respond_to?(:define_method) | |
=> false | |
[3] pry(main)> Class.new.send(:define_method, :yup) {} | |
=> #<Proc:0x00000100a08cb8@(pry):3 (lambda)> | |
[4] pry(main)> Module.new.send(:define_method, :yup) {} | |
=> #<Proc:0x00000100d8f468@(pry):4 (lambda)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As @JEG2 kindly pointed out: https://twitter.com/JEG2/status/370268287675805696
facepalm
For the record,
Module#respond_to?
takes an optional parameter to include private methods:[9] pry(main)> Module.new.respond_to?(:define_method, true)
=> true