Skip to content
instance method

String#*

(::int amount) -> ::String
self * n → new_string

Returns a new string containing n copies of self:

Example
'Ho!' * 3 # => "Ho!Ho!Ho!"
'No!' * 0 # => ""

Related: see Converting to New String.

Ruby version changes

  1. 3.0
See also #% #+ .try_convert #+@ also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0