collect items from given collection condition while is true
Parameters
collect collection :integer :string :literal :dictionary :object :inline :block :range
params :null :literal :block
condition :block :bytecode
Attributes
with |
:literal |
use given index |
after |
|
start collecting after given condition becomes true |
Returns
Examples
copy
collect [1 3 5 4 6 7] => odd?
; => [1 3 5]
collect [1 2 3 4 3 2 1 2 3] 'x -> x < 4
; => [1 2 3]
copy
collect.after [4 6 3 5 2 0 1] => odd?
; => [3 5 2 0 1]
collect.after 1..10 'x -> x > 4
; => [5 6 7 8 9 10]
Related