Skip to content

Instantly share code, notes, and snippets.

@aarti
Created October 22, 2014 21:13
Show Gist options
  • Save aarti/5de3952b998010c9c28b to your computer and use it in GitHub Desktop.
Save aarti/5de3952b998010c9c28b to your computer and use it in GitHub Desktop.
ruby integers can be accessed as binary arrays
irb(main):019:0> a
=> 12
irb(main):014:0> a.to_s(2)
=> "1100"
irb(main):015:0> a[0]
=> 0
irb(main):016:0> a[1]
=> 0
irb(main):017:0> a[2]
=> 1
irb(main):018:0> a[3]
=> 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment