diff options
| author | ksss <[email protected]> | 2017-01-04 14:00:28 +0900 |
|---|---|---|
| committer | ksss <[email protected]> | 2017-01-04 14:00:28 +0900 |
| commit | eeca6ec8f511933e9a403e6b6166b874eead25b1 (patch) | |
| tree | 5a5ec5b64a63b93f19cb49c175a90adff0d7a1ac /mrbgems/mruby-string-ext/mrblib/string.rb | |
| parent | 158a6ab2ed64a448d7345d56d1d7430a9f52d4b8 (diff) | |
| download | mruby-eeca6ec8f511933e9a403e6b6166b874eead25b1.tar.gz mruby-eeca6ec8f511933e9a403e6b6166b874eead25b1.zip | |
Rewrite String#prepend with Ruby
Fix #3357
Diffstat (limited to 'mrbgems/mruby-string-ext/mrblib/string.rb')
| -rw-r--r-- | mrbgems/mruby-string-ext/mrblib/string.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/mrbgems/mruby-string-ext/mrblib/string.rb b/mrbgems/mruby-string-ext/mrblib/string.rb index e6fbe7ddc..6e5f3c73d 100644 --- a/mrbgems/mruby-string-ext/mrblib/string.rb +++ b/mrbgems/mruby-string-ext/mrblib/string.rb @@ -385,4 +385,18 @@ class String end end alias each_codepoint codepoints + + ## + # call-seq: + # str.prepend(other_str) -> str + # + # Prepend---Prepend the given string to <i>str</i>. + # + # a = "world" + # a.prepend("hello ") #=> "hello world" + # a #=> "hello world" + def prepend(arg) + self[0, 0] = arg + self + end end |
