string_duplication
✖️ Duplicating Strings with *
You can repeat a string multiple times using the *
operator. This is concise for creating repeated patterns or padding.
pattern = "ha"
laugh = pattern * 3
puts laugh # => "hahaha"
*
You can repeat a string multiple times using the *
operator. This is concise for creating repeated patterns or padding.
pattern = "ha"
laugh = pattern * 3
puts laugh # => "hahaha"