[macruby-changes] [5252] MacRuby/trunk/string.c
source_changes at macosforge.org
source_changes at macosforge.org
Fri Mar 4 15:05:12 PST 2011
Revision: 5252
http://trac.macosforge.org/projects/ruby/changeset/5252
Author: watson1978 at gmail.com
Date: 2011-03-04 15:05:12 -0800 (Fri, 04 Mar 2011)
Log Message:
-----------
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
}}}
Modified Paths:
--------------
MacRuby/trunk/string.c
Modified: MacRuby/trunk/string.c
===================================================================
--- 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);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110304/de0b19a9/attachment.html>
More information about the macruby-changes
mailing list