take until nil : take_while « Array « Ruby






take until nil


[1,2,3,nil,4].take_while {|x| x }  # => [1,2,3]: take until nil

 

Related examples in the same category