Skip to content

Commit bf8fc47

Browse files
committed
Fix generator xrange() example
Patch by KodyWiremane. Closes #4. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@347735 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 7e14c2a commit bf8fc47

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

language/generators.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,20 @@
4949
<![CDATA[
5050
<?php
5151
function xrange($start, $limit, $step = 1) {
52-
if ($start < $limit) {
52+
if ($start <= $limit) {
5353
if ($step <= 0) {
54-
throw new LogicException('Step must be +ve');
54+
throw new LogicException('Step must be positive');
5555
}
5656
5757
for ($i = $start; $i <= $limit; $i += $step) {
5858
yield $i;
5959
}
6060
} else {
6161
if ($step >= 0) {
62-
throw new LogicException('Step must be -ve');
62+
throw new LogicException('Step must be negative');
6363
}
6464
65-
for ($i = $start; $i >= $limit; $i -= $step) {
65+
for ($i = $start; $i >= $limit; $i += $step) {
6666
yield $i;
6767
}
6868
}

0 commit comments

Comments
 (0)