string-ext/string.rb: String#prepend to take multiple arguments.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-09-20 18:27:18 +09:00
parent 4cba1b49c0
commit 11504318b8
+6 -2
View File
@@ -334,8 +334,12 @@ class String
# a = "world"
# a.prepend("hello ") #=> "hello world"
# a #=> "hello world"
def prepend(arg)
self[0, 0] = arg
def prepend(*args)
len = args.size
while len > 0
len -= 1
self[0, 0] = args[len]
end
self
end