DEV Community

Discussion on: Multiply a string? 🤔

Collapse
 
misobelica profile image
Mišo

In Python, you can do "string" * 3 but the result is "stringstringstring".

In Kotlin for example you can do extension function that overloads operator on string but I would not recommend it because it's not very intuitive.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

That's cool, what about python integer multiply 🤔 maybe it's not such a crazy thought.

(I must learn kotlin soon)

Collapse
 
misobelica profile image
Mišo • Edited

While I sometimes use it in Python for delimiters in print("-" * 100) I don't think it's a big feature worth to spread. I think the method "*".repeat(100) would be more clear for people.