module Iterable(T)
¶
The Iterable
mixin provides convenience methods to collection classes
that provide an each
method that returns an Iterator
over the collection.
Direct including types
Dir
Hash(K, V)
Indexable(T)
Range(B, E)
Set(T)
Methods¶
#chunk(reuse = false, &block : T -> U) forall U
¶
(reuse = false, &block : T -> U) forall U
Returns an Iterator that enumerates over the items, chunking them together based on the return value of the block.
(0..7).chunk(&.//(3)).to_a # => [{0, [0, 1, 2]}, {1, [3, 4, 5]}, {2, [6, 7]}]
See also: Iterator#chunks
.
#chunk_while(reuse : Bool | Array(T) = false, &block : T, T -> B) forall B
¶
(reuse : Bool | Array(T) = false, &block : T, T -> B) forall B
Same as each.chunk_while(reuse, &block)
.
#slice_after(reuse : Bool | Array(T) = false, &block : T -> B) forall B
¶
(reuse : Bool | Array(T) = false, &block : T -> B) forall B
Same as each.slice_after(reuse, &block)
.
#slice_after(pattern, reuse : Bool | Array(T) = false)
¶
(pattern, reuse : Bool | Array(T) = false)
Same as each.slice_after(pattern, reuse)
.
#slice_before(reuse : Bool | Array(T) = false, &block : T -> B) forall B
¶
(reuse : Bool | Array(T) = false, &block : T -> B) forall B
Same as each.slice_before(reuse, &block)
.
#slice_before(pattern, reuse : Bool | Array(T) = false)
¶
(pattern, reuse : Bool | Array(T) = false)
Same as each.slice_before(pattern, reuse)
.
#slice_when(reuse : Bool | Array(T) = false, &block : T, T -> B) forall B
¶
(reuse : Bool | Array(T) = false, &block : T, T -> B) forall B
Same as each.slice_when(reuse, &block)
.