Skip to content

Instantly share code, notes, and snippets.

@bhelx
Created January 21, 2012 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhelx/1654178 to your computer and use it in GitHub Desktop.
Save bhelx/1654178 to your computer and use it in GitHub Desktop.
reduce bitwise OR flags
REG_EXTENDED = 1
REG_ICASE = (REG_EXTENDED << 1)
REG_NOSUB = (REG_ICASE << 1)
REG_NEWLINE = (REG_NOSUB << 1)
flags = [REG_EXTENDED, REG_NOSUB]
p flags.reduce :|
# => 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment