Forum: wxRuby Colour bug ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ridge M. (Guest)
on 2009-02-01 04:04
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
Alex F. (Guest)
on 2009-02-01 05:35
(Received via mailing list)
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/2...

a
This topic is locked and can not be replied to.