[MacRuby-devel] Bug in string comparison?

Mark Rada mrada at marketcircle.com
Wed Apr 6 21:12:31 PDT 2011


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



More information about the MacRuby-devel mailing list