From: Stephen White Date: 2001-02-18T21:47:18+09:00 Subject: [ruby-talk:11052] Re: to_s and << On Sun, 18 Feb 2001, Stephen White wrote: > str1 = rb_str_append(str1, str2); Gawd, I'm thick. I overlooked this when it was jumping up and down and kicking me in the nuts. Must have lost feeling down there from all the other times I've been thick. :) In abject apology, here's the right answer (I think!)... Init_String has: rb_define_method(rb_cString, "<<", rb_str_concat, 1); rb_str_concat(str1, str2) has: str1 = rb_str_append(str1, str2); rb_str_append(str1, str2) has: if (TYPE(str2) != T_STRING) str2 = rb_str_to_str(str2); rb_str_to_str(str) has: return rb_convert_type(str, T_STRING, "String", "to_str"); Which explains why aliasing 'to_s' to 'to_str' enables the automatic conversions. One day I'll manage to make a posting here without 5 follow-up corrections. -- spwhite@chariot.net.au