Add isEmpty to Sequence.
Thanks, Michel and Thorbjørn!
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user