« Bugzilla Issues Index
#922 — 15.5.4.21 String.prototype.repeat should allow a count value of 0
- bug_id:
922
- creation_ts:
2012-11-02 17:04:00 -0700
- short_desc:
15.5.4.21 String.prototype.repeat should allow a count value of 0
- delta_ts:
2012-12-21 18:08:47 -0800
- product:
Draft for 6th Edition
- component:
technical issue
- version:
Rev 12: November 22, 2012 Draft
- rep_platform:
All
- op_sys:
All
- bug_status:
RESOLVED
- resolution:
FIXED
- priority:
Normal
- bug_severity:
minor
- everconfirmed:
true
- reporter:
Claude Pache
- assigned_to:
Allen Wirfs-Brock
- cc:
["brendan", "claude.pache", "tobie.langel"]
- commentid:
2409
- comment_count:
0
- who:
Claude Pache
- bug_when:
2012-11-02 17:04:09 -0700
Repeating a string 0 time should yield an empty string.
According to the current version of the spec, it throws a RangeError (at step 6).
- commentid:
2547
- comment_count:
1
- who:
Tobie Langel
- bug_when:
2012-11-22 12:51:15 -0800
For reference, in Ruby:
irb(main):008:0> 'foo' * 3
=> "foofoofoo"
irb(main):009:0> 'foo' * 1
=> "foo"
irb(main):010:0> 'foo' * 0
=> ""
irb(main):011:0> 'foo' * -1
ArgumentError: negative argument
from (irb):11:in `*'
from (irb):11
- commentid:
2559
- comment_count:
2
- who:
Brendan Eich
- bug_when:
2012-11-22 21:50:11 -0800
See also http://rosettacode.org/wiki/Repeat_a_string.
/be
- commentid:
2972
- comment_count:
3
- who:
Allen Wirfs-Brock
- bug_when:
2012-12-01 11:43:35 -0800
fixed in rev 13 editor's draft