From: Jens Nissen Date: 2001-12-20T00:11:42+09:00 Subject: [ruby-talk:28940] Question on String Handling in Ruby 1.6.6. I'm using ruby 1.6.6 (2001-12-13) [i586-mswin32]. (1.6.5 does not have the problem!) Watch the following script in an environment, which has a trace_func set. #begin demo a = "Hello" puts "Bug!" if a != nil #end demo What I see, is that an exception is raised, but handled internally. That's very annoying for Users using a debugger. Looking at the source code, I'd like to raise some questions (in addition to the exception :-)) (1) object.c::rb_check_convert_type - What is arg2 good for? - What is the first checking of val good for - the function is only called, if TYPE(val) != type (see rb_str_equal) The code looks somewhat incomplete so I'm rather suspicious of this code. (It wasn't part of 1.6.5) (2) Is the following code a bug in string.c::rb_str_equal? //quote ... if (TYPE(str2) != T_STRING) { str2 = rb_check_convert_type(str2, T_STRING, "String", "to_str"); if (NIL_P(str2)) return Qfalse; } //end quote This code tries to call the method to_str on objects which are not strings. But to_str is defined only for Strings (and Exceptions). Would it be correct to call "to_s" instead, which is defined for most Objects and thus makes more sense? Jens