From: ts Date: 2002-01-01T21:16:05+09:00 Subject: [ruby-talk:29947] Re: A Bug or something else? >>>>> "m" == writes: m> It works. Thanks. But would it have any side effects? I wonder why "private" m> did not disable the outside access to "nil". I asked a question before Well, in ruby a private method is a method that can be called only in a function form (i.e. it can have only self as a receiver). Here you are in a special where ruby want to convert a value to a string, and in this case it can call any methods (public, private, ...) m> about the reasoning for the existence of methods for "nil", such as "to_a", m> "to_i", "to_s". Can an exception be raised for this scenario and the one m> below? m> a = nil m> a == 1 => false (even after the undef) Well here you have written something like a.== 1 this mean that if you undef #== for NilClass it will work pigeon% ruby class NilClass undef == end a = nil a == 1 ^D -:5: undefined method `==' for nil (NameError) pigeon% it's still work with 1 == a but this is a special case and will not do what you want with (for example) [] == a m> "a=nil" may be seen as creating a variable but no real value assigned yet. For me, this case is more `undef' than `nil' m> Should the "a == 1" be invalid? not for me Guy Decoux