Created
April 27, 2015 20:56
-
-
Save taf2/a01bd2637f86ac204196 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class Bar | |
| def calls | |
| ['a','b','c','d'].each do|i| | |
| yield i | |
| end | |
| end | |
| def hello | |
| self.calls do|call| | |
| puts call | |
| end | |
| end | |
| end | |
| Bar.new.hello | |
| def new_calls(&block) | |
| ['z','y','x'].each do|i| | |
| yield i | |
| end | |
| end | |
| bar = Bar.new | |
| bar.instance_eval do | |
| def calls(&block) | |
| new_calls(&block) | |
| end | |
| end | |
| bar.hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment