"string".repeat(0)
# David Bruant (13 years ago)
Le 22/11/2012 21:44, Allen Wirfs-Brock a écrit :
See ecmascript#922
What do people think? Should a repeat count of 0 be accepted and produce an empty string?
I would expect so.
# Brendan Eich (13 years ago)
David Bruant wrote:
Le 22/11/2012 21:44, Allen Wirfs-Brock a écrit :
See ecmascript#922
What do people think? Should a repeat count of 0 be accepted and produce an empty string? I would expect so.
Definitely. 0 is the basis case, not 1. See Ruby (as noted in the bug), also Perl, PHP, and many, many other languages:
See ecmascript#922
What do people think? Should a repeat count of 0 be accepted and produce an empty string? Does this case show up frequently in string processing algorithms?