Created
October 28, 2011 19:13
-
-
Save hoff2/1323195 to your computer and use it in GitHub Desktop.
overriding #call in the singleton class of a Proc, a bad idea in the first place, but also:
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
ruby-1.9.2-p290 :030 > a = proc{'eh'} | |
=> #<Proc:0x000001009ac850@(irb):30> | |
ruby-1.9.2-p290 :031 > a.() | |
=> "eh" | |
ruby-1.9.2-p290 :032 > a[] | |
=> "eh" | |
ruby-1.9.2-p290 :033 > a.call | |
=> "eh" | |
ruby-1.9.2-p290 :034 > def a.call; super + '?'; end | |
=> nil | |
ruby-1.9.2-p290 :035 > a.() | |
=> "eh?" | |
ruby-1.9.2-p290 :036 > a[] | |
=> "eh" | |
ruby-1.9.2-p290 :037 > a.call | |
=> "eh?" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ideas: