alcina
October 17, 2013, 9:18pm
1
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.
In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Most familiar as the name of the property that says something like "3 + 4 = 4 + 3" or "2 × 5 = 5 × 2", the property can also be used in more advanced settings. The name is needed because there are operations, such as division and subtraction, that do not have it (for example, "3 − 5 ...
Cheers
robert
my-ruby
October 17, 2013, 10:05pm
8
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 -