Created
May 7, 2012 15:05
-
-
Save padde/2628262 to your computer and use it in GitHub Desktop.
Ruby Fixnum each_bit
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
class Fixnum | |
def each_bit | |
8.times do |p| | |
yield (self & 1 << p) >> p | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment