Repeat a string: Difference between revisions

no edit summary
No edit summary
Line 586:
<lang python>"ha" * 5 # ==> "hahahahaha"</lang>
"Characters" are just strings of length one.
 
the other way also works:
<lang python>5 * "ha" # ==> "hahahahaha"</lang>
 
=={{header|R}}==
Line 648 ⟶ 651:
=={{header|Ruby}}==
<lang ruby>"ha" * 5 # ==> "hahahahaha"</lang>
Despite the use of the * operator, the operation is not commutative:
<lang ruby>5 * "ha" # TypeError: String can't be coerced into Fixnum</lang>
 
=={{header|Scala}}==
Anonymous user