Add isEmpty to Sequence.

Thanks, Michel and Thorbjørn!
This commit is contained in:
Bob Nystrom
2015-06-30 06:52:29 -07:00
parent ed6d7c5084
commit 4a15653c66
4 changed files with 21 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
IO.print([].isEmpty) // expect: true
IO.print([1].isEmpty) // expect: false
class InfiniteSequence is Sequence {
iterate(iterator) { true }
iteratorValue(iterator) { iterator }
}
// Should not try to iterate the whole sequence.
IO.print((new InfiniteSequence).isEmpty) // expect: false