diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-04-28 21:37:56 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-04-28 21:41:01 +0900 |
| commit | e5e5acefaf922243aef707d8eff77f7e22db03fa (patch) | |
| tree | 01d245f969c2e2169aeca49980f52c6a81c87150 /mrblib | |
| parent | 6666b4fa621a197bf15be11df0e1eb29b8588143 (diff) | |
| download | mruby-e5e5acefaf922243aef707d8eff77f7e22db03fa.tar.gz mruby-e5e5acefaf922243aef707d8eff77f7e22db03fa.zip | |
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`
Diffstat (limited to 'mrblib')
| -rw-r--r-- | mrblib/string.rb | 13 |
1 files changed, 2 insertions, 11 deletions
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 |
