> Can't reproduce with what you've given.
>
> ruby-1.9.1-p376 > class A
> ruby-1.9.1-p376 ?>  attr_accessor :slot
> ruby-1.9.1-p376 ?>  def matches? s
> ruby-1.9.1-p376 ?>    puts "s <=> @slot = #{s <=> @slot}"
> ruby-1.9.1-p376 ?>    (s <=> @slot) == 0
> ruby-1.9.1-p376 ?>    end
> ruby-1.9.1-p376 ?>  end
>  => nil
> ruby-1.9.1-p376 > a = A.new
>  => #<A:0x000000041915b8>
> ruby-1.9.1-p376 > a.slot = "dog"
>  => "dog"
> ruby-1.9.1-p376 > a.matches? "dog"
> s <=> @slot = 0
>  => true
> ruby-1.9.1-p376 >
>
> String comparison via <=> to nil will return nil. Are you entirely sure
> that in your IRB session your object's @slot isn't nil for some reason?

First, yep, 100% sure that @slot wasn't nil -- I printed it out upon
entering the matches? method.  (FWIW, you have it reversed: irb
session worked fine.  Driven from a script failed.)  Sadly, my
attempts to prune down the example to a reproducible losing case have
failed to fail, so to speak.  As suggested by @Matt Brown, I'll take
this over to the ruby-talk list.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to