Last active
December 24, 2015 16:58
-
-
Save darrend/6831636 to your computer and use it in GitHub Desktop.
Is there a tighter way to do this?
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
num_fragments = 0 | |
counter = lambda { num_fragments += 1 } |
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
counter = Class.new do | |
def initialize | |
@counter = 0 | |
end | |
def next | |
@counter += 1 | |
end | |
end.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment