String#+ will concatenate only strings.
Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
assert_equal("foobar", "foo" + "bar" )
assert_raise(TypeError){ "foo" + :bar }
puts :ok
}}}
--- MacRuby/trunk/string.c 2011-03-04 11:55:41 UTC (rev 5251)
+++ MacRuby/trunk/string.c 2011-03-04 23:05:12 UTC (rev 5252)
@@ -2533,6 +2533,8 @@
static VALUE
rstr_plus(VALUE self, SEL sel, VALUE other)
{
+ StringValue(other);
+
rb_str_t *newstr = str_dup(RSTR(self));
rb_str_t *otherstr = str_need_string(other);
str_concat_string(newstr, otherstr);