Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 345 Bytes

File metadata and controls

22 lines (17 loc) · 345 Bytes

str_repeat

Repeating a string in Ruby uses the multiplication operator -- the String#* method.

{{code:php $result = str_repeat("abc", 5); var_export($result); // => 'abcabcabcabcabc' }}

{{code:ruby result = "abc" * 5 p result # => "abcabcabcabcabc" }}

{{related: strings/str_pad strings/substr_count }}