[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour

Thibaut Barrère thibaut.barrere at gmail.com
Tue Mar 3 15:46:03 EST 2009


while writing specs for Magic, I noticed that:

instance_from(MenuItem, "Hello").text.*to_s*.should == "Hello"

to_s is required to get the assertion to pass. The following will return

button = Button.new
button.text = "Hello"
puts button.text == "Hello"

So I guess that CLR strings cannot be compared to Ruby strings unless to_s
is applied.

While not a big deal, it's a bit surprising.

Is it something that is likely to change ?


-- Thibaut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090303/1da62b2f/attachment.html>

More information about the Ironruby-core mailing list