Colour bug?

Here is some code to demonstrate that
“==” doesn’t seem to work completely for colour.

The only problem I’ve noticed is when testing
against nil.

#---------------------------------------------------
require ‘wx’
include Wx

class Demo
def try(arg)
if (arg == nil)
result = “Nil”
elsif (arg.is_a?(Array))
result = “Array”
elsif (arg.is_a?(Colour))
result = “Colour”
elsif (arg.is_a?(String))
result = “String”
else
result = “Unclassified”
end

puts result
end
end

bd = Demo.new

n = nil
bd.try(n)

array = %w(one two)
bd.try(array)

string = “abc”
bd.try(string)

colour = Colour.new(0, 0, 0, 255)
bd.try(colour)

An interesting work-around is to put the
Colour test first. However, it sure
would be nice if Colour worked like the
other objects.

Ridge

Hi

Ridge M. wrote:

class Demo
result = “Unclassified”

An interesting work-around is to put the
Colour test first. However, it sure
would be nice if Colour worked like the
other objects.

Thanks for the report. wxRuby shouldn’t be so stern. It’s fixed by
SVN:1990

http://rubyforge.org/pipermail/wxruby-svn-commit/2009-January/000846.html

a