method

[]

Importance_1
v2_4_6 - Show latest stable - 0 notes - Class: Integer
[](p1) public

Bit Reference—Returns the +n+th bit in the binary representation of int, where int[0] is the least significant bit.

For example:

a = 0b11001100101010
30.downto(0) do |n| print a[n] end
#=> 0000000000000000011001100101010

a = 9**15
50.downto(0) do |n|
  print a[n]
end
#=> 000101110110100000111000011110010100111100010111001
Show source
Register or log in to add new notes.