From e5e5acefaf922243aef707d8eff77f7e22db03fa Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 28 Apr 2021 21:37:56 +0900 Subject: string.{c,rb}: fix type of return values from some methods as Ruby3.0 When the receiver is the instance of subclass of `String`. - `String#each_char` - `String#each_line` - `String#partition` --- mrblib/string.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'mrblib') diff --git a/mrblib/string.rb b/mrblib/string.rb index 0e7c8dc12..675026e73 100644 --- a/mrblib/string.rb +++ b/mrblib/string.rb @@ -29,25 +29,16 @@ class String string = dup self_len = length sep_len = separator.length - should_yield_subclass_instances = self.class != String while (pointer = string.index(separator, start)) pointer += sep_len pointer += 1 while paragraph_mode && string[pointer] == "\n" - if should_yield_subclass_instances - block.call(self.class.new(string[start, pointer - start])) - else - block.call(string[start, pointer - start]) - end + block.call(string[start, pointer - start]) start = pointer end return self if start == self_len - if should_yield_subclass_instances - block.call(self.class.new(string[start, self_len - start])) - else - block.call(string[start, self_len - start]) - end + block.call(string[start, self_len - start]) self end -- cgit v1.2.3