This actually makes my problem worse! Now there is no way of catching the times when I accidentally return a CLR string rather than a MutableString. It will only flag up when client code tries to call a MutableString method on the CLR string. Pete
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Lam (IRONRUBY) Sent: Thursday,08 May 08, 2008 17:23 To: [email protected] Subject: Re: [Ironruby-core] Forgetting MutableString Peter Bacon Darwin: > I keep forgetting to wrap up CLR strings in MutableStrings when > returning strings retrieved from calls to .NET Framework library > methods. I finally understand what this is ... is this what you're looking for? public override bool Equals(object other) { if (other is MutableString) return Equals(other as MutableString); else if (other is string) return Equals(other as string); else return false; } public bool Equals(string other) { if (other == null) return false; if (_data.Length != other.Length) return false; for (int i = 0; i < _data.Length; ++i) if (_data[i] != other[i]) return false; return true; } public bool Equals(MutableString other) { if (ReferenceEquals(this, other)) return true; if (other == null) return false; if (_data.Length != other.Length) return false; for (int i = 0; i < _data.Length; ++i) if (_data[i] != other.Chars[i]) return false; return true; } If so, it's coming in the next release. Thanks, -John _______________________________________________ Ironruby-core mailing list [email protected] http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list [email protected] http://rubyforge.org/mailman/listinfo/ironruby-core
