On Fri, Nov 7, 2008 at 3:51 PM, Pat Maddox <[EMAIL PROTECTED]> wrote:

> "Greg Hauptmann" <[EMAIL PROTECTED]> writes:
>
> Do you mean BigDecimal?  Anyway, you should probably be using == instead
> of eql.
>
> >> 5.5 == BigDecimal.new('5.5')
> => true
> >> 5.5.eql? BigDecimal.new('5.5')
> => false
>
> eql? is object identity and is generally not what you're after.
>

Yeah, but

>> BigDecimal('5.5').eql? BigDecimal('5.5')
=> true

So it's either creating value objects (like Symbol) or BigDecimal.eql?
doesn't do object equality.

What's interesting is that you can create BigDecimals this way (without
calling new). You can do it with Strings, too.

>> String('asdf')
=> "asdf"

But not everything:

>> Hash(:a => 5)
NoMethodError: undefined method `Hash' for #<Object:0x3799c>
    from (irb):12

As Johnny Carson used to say, "I did not know that."

///ark
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to