[MacRuby-devel] Bug in string comparison?
Mark Rada
mrada at marketcircle.com
Wed Apr 6 21:35:53 PDT 2011
Nevermind. The problem is not related to the string class, I'm just dumb and didn't realize I created a literal array.
Mark Rada
mrada at marketcircle.com
On 2011-04-07, at 12:12 AM, Mark Rada wrote:
> I've got a strange behaviour during string comparison that boils down to the following:
>
>
> class NSString
> def predicate?
> [-1] == '?'
> end
> end
>
> puts '?'.predicate? # => false
> puts '?'[-1] # => "?"
> puts '?'[-1] == '?' # => true
>
>
> I'm not sure if this is a known side effect of how Strings are implemented now or if it is simply a bug.
>
> I know it will work if I use a regexp, but this method is less code and faster.
>
> Thoughts?
>
>
> Thanks,
>
> Mark Rada
> mrada at marketcircle.com
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
More information about the MacRuby-devel
mailing list