Skip to content

Commit

Permalink
Add guard to skip: to report negative count
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvc committed Sep 28, 2023
1 parent 3b35e0f commit 19dbf9e
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ skip: count
"Skip over count elements.
This could be further optimzed."

count < 0 ifTrue: [ self error: 'cannot skip backwards' ].
count timesRepeat: [ self next ]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
accessing
skip: anInteger

anInteger < 0 ifTrue: [ self error: 'cannot skip backwards' ].
self readingActionDo: [
readStream skip: anInteger ]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
skip: anInteger

anInteger < 0 ifTrue: [ self error: 'cannot skip backwards' ].
readStream skip: anInteger
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accessing
skip: count
count < 0 ifTrue: [ self error: 'cannot skip backwards' ].
count timesRepeat: [ self next ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accessing
skip: count
count < 0 ifTrue: [ self error: 'cannot skip backwards' ].
count timesRepeat: [ self next ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accessing
skip: count
count < 0 ifTrue: [ self error: 'cannot skip backwards' ].
count timesRepeat: [ self next ]

0 comments on commit 19dbf9e

Please sign in to comment.