I know of Python's list
method that can consume all elements from a generator. Is there something like that available in Ruby?
I know of :
elements = []
enumerable.each {|i| elements << i}
I also know of the inject
alternative. Is there some ready available method?
Enumerable#to_a
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With