Method: Immutable.stream
- Defined in:
- lib/immutable/list.rb
.stream(&block) ⇒ List
Create a lazy, infinite list.
The given block is called as necessary to return successive elements of the list.
22 23 24 25 |
# File 'lib/immutable/list.rb', line 22 def stream(&block) return EmptyList unless block_given? LazyList.new { Cons.new(yield, stream(&block)) } end |