Skip to content

Commit

Permalink
fix a bug in NSString#== where an exception would occur if the operan…
Browse files Browse the repository at this point in the history
…d cannot be converted as a string

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4035 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
lrz committed May 6, 2010
1 parent 6f24970 commit 68eebf6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions NSString.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@
static VALUE
nsstr_equal(id rcv, SEL sel, VALUE other)
{
if (rcv == (id)other) {
return Qtrue;
}
if (TYPE(other) != T_STRING) {
if (!rb_respond_to(other, rb_intern("to_str"))) {
return Qfalse;
}
return rb_equal(other, (VALUE)rcv);
}
return [rcv isEqualToString:(id)to_str(other)] ? Qtrue : Qfalse;
}

Expand Down

0 comments on commit 68eebf6

Please sign in to comment.