Ruby 4.1 リファレンスマニュアル

instance method String#prepend

prepend(other_str) -> StringRuby 1.9.3 から[permalink][rdoc][edit]

文字列 other_str を先頭に破壊的に追加します。

[PARAM] other_str:
追加したい文字列を指定します。
a = "world"
p a.prepend("hello ") # => "hello world"
p a                 # => "hello world"
prepend(*arguments) -> StringRuby 1.9.3 から[permalink][rdoc][edit]

複数の文字列を先頭に破壊的に追加します。

[PARAM] arguments:
追加したい文字列を指定します。
a = "!!!"
p a.prepend # => "!!!"
p a       # => "!!!"

a = "!!!"
p a.prepend "hello ", "world" # => "hello world!!!"
p a                         # => "hello world!!!"