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