Skip to content

Commit

Permalink
String#succ will return subclass instance.
Browse files Browse the repository at this point in the history
Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

class SubStr < String
  def value
    "value : " + self
  end
end

str = SubStr.new("abcd")
assert_equal(SubStr, str.succ.class)

puts :ok
}}}
  • Loading branch information
Watson1978 committed Apr 22, 2011
1 parent 6113814 commit be34f68
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions string.c
Expand Up @@ -5071,6 +5071,7 @@ rstr_succ(VALUE str, SEL sel)
VALUE newstr = rb_enc_str_new(chars_ptr, len, RSTR(str)->encoding);
free(chars_buf);
OBJ_INFECT(newstr, str);
SET_CLASS(newstr, str);

return newstr;
}
Expand Down

0 comments on commit be34f68

Please sign in to comment.