Created
December 11, 2011 02:22
-
-
Save pasberth/1457770 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
| module NormallyCase; extend self; end | |
| module NormallyCase | |
| def count_up | |
| @count ||= 0 | |
| @count += 1 | |
| end | |
| def count_down | |
| @count ||= 0 | |
| @count -= 1 | |
| end | |
| end | |
| module FlattenScopeCase; extend self; end | |
| FlattenScopeCase.module_eval do | |
| count = 0 | |
| define_method :count_up do | |
| count += 1 | |
| end | |
| define_method :count_down do | |
| count -= 1 | |
| end | |
| end | |
| puts NormallyCase.count_up # 1 | |
| puts NormallyCase.count_down # 0 | |
| puts FlattenScopeCase.count_up # 1 | |
| puts FlattenScopeCase.count_down # 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment