Created
September 26, 2012 02:54
-
-
Save mizoR/3785734 to your computer and use it in GitHub Desktop.
インスタンスメソッドの中で、メソッド定義を書いたときの挙動
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
➜ ~ irb | |
irb(main):001:0> class MyClass | |
irb(main):002:1> def one | |
irb(main):003:2> def two | |
irb(main):004:3> 'hello' | |
irb(main):005:3> end | |
irb(main):006:2> end | |
irb(main):007:1> end | |
=> nil | |
irb(main):008:0> MyClass.instance_methods(false).grep /one/ | |
=> [:one] | |
irb(main):009:0> MyClass.instance_methods(false).grep /two/ | |
=> [] | |
irb(main):010:0> MyClass.new.one | |
=> nil | |
irb(main):011:0> MyClass.instance_methods(false).grep /two/ | |
=> [:two] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment