Created
January 4, 2012 08:18
-
-
Save mana8626/1559071 to your computer and use it in GitHub Desktop.
eachを実装してみたった!
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 Array | |
def eachfor &blk | |
i = 0 | |
while i < self.length | |
blk.call self[i] | |
end | |
i += 1 | |
end | |
end | |
end | |
[1, 2, 3, 4, 5, 6].eachfor do |e| | |
puts e * e | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment