Confusion with Ruby binary number

Can anyone tell me what’s happening in the below code ?

c = 0b101010011
c # => 339
c[0] # => 1
c[1] # => 1
c[2] # => 0
c[3] # => 0
c[4] # => 1

here c is not an array,but how then c[0],c[1], etc producing output
and how those outputs are coming ?

See Class: Fixnum (Ruby 1.9.3) for
example.
Nothing special, just another method lookup.

Adam P. wrote in post #1124779:

See Class: Fixnum (Ruby 1.9.3) for
example.
Nothing special, just another method lookup.

Ohh! somehow I overlooked that method in the documentation.

Thanks

On Oct 17, 2013, at 2:21 PM, Adam P. [email protected] wrote:

See Class: Fixnum (Ruby 1.9.3) for example.
Nothing special, just another method lookup.

You truly do have superpowers.

Adam P. wrote in post #1124779:

See Class: Fixnum (Ruby 1.9.3) for
example.
Nothing special, just another method lookup.

can you explain the below code ?

12 === Fixnum # => false
Fixnum === 12 # => true

Why different result is getting printed?

I think it’s a matter of order it comes in.

It is similar to saying

"string’ === String # => false
String === “string” # => true.

On Fri, Oct 18, 2013 at 3:48 PM, John M. [email protected] wrote:

I think it’s a matter of order it comes in.

It is similar to saying

"string’ === String # => false
String === “string” # => true.

Cheers

robert

Love U Ruby wrote in post #1124783:

Adam P. wrote in post #1124779:

See Class: Fixnum (Ruby 1.9.3) for
example.
Nothing special, just another method lookup.

can you explain the below code ?

12 === Fixnum # => false
Fixnum === 12 # => true

Why different result is getting printed?

After spending some time I figured it out:

Why Fixnum === 12 # => true ?

Fixnum.respond_to?(:===) # => true
Fixnum.method(:===).owner # => Module

As per the documentation of Module#===

Case Equality—Returns true if anObject is an instance of mod or one
of mod’s descendants. Of limited use for modules, but can be used in
case statements to classify objects by class.

Why 12 === Fixnum # => false ?

Got answer from here -