[Ironruby-core] Forgetting MutableString

Peter Bacon Darwin bacondarwin at googlemail.com
Thu May 8 08:47:02 EDT 2008

I keep forgetting to wrap up CLR strings in MutableStrings when returning
strings retrieved from calls to .NET Framework library methods.


I had this RSpec that had something like:


some_array[3].should == "some mutable string"


that was failing with the error:


Expected "some mutable string" to equal "some mutable string":


It would be great if there were some way of picking this up, possibly at
compile time (possibly with SpecSharp??) or may be more simply changing the
way a CLR string is printed in the console so that it is different from a


For instance how about a CLR string being printed out as <<my CLR string>>
or <CLR String "my CLR string"> or something.  This could be a debug thing
only if you wanted.  Then the error message would be:


Expected <<some mutable string>> to equal "some mutable string"


Which makes it more clear what is wrong, even if you don't know the


[I realise that I ought to just check that the class of the some_array[3]
was actually String in the first place but this would still help.]

[Also, I realise that there is no implicit conversion between CLR string and
MutableString, so if the method was typed to return a MutableString then
this would not compile, but Ruby doesn't half like having stuff returned in
arrays, so you lose the strong typing]


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080508/40b13d6c/attachment.html>

More information about the Ironruby-core mailing list