Hi ,


I ran the below code to do some test on <=>,==,===,eql?,equal? I took 1
and 1.o to perform my test.

Part-I : output is saying 1 and 1.0 are equal - as per mathematical
knowledge it is right.

irb(main):009:0> 1<=>1.01
=> -1
irb(main):010:0> 1<=>1.0
=> 0
irb(main):011:0> 1==1.0
=> true
irb(main):012:0> 1===1.0
=> true

Part- II

Here why the opposite output comes here, how it comes? what computation
Ruby did on these?

irb(main):015:0> 1.eql? 1.0
=> false
irb(main):016:0> 1.equal? 1.0
=> false
irb(main):017:0>

-- 
Posted via http://www.ruby-forum.com/.