What is the Ruby equivalent of the chain iterator in python?
data_chained = []
data2 = {}
data_chained = chain(data_chained, data2)
How can this be done in Ruby?
What is the Ruby equivalent of the chain iterator in python?
data_chained = []
data2 = {}
data_chained = chain(data_chained, data2)
How can this be done in Ruby?
Is this what you are looking for?
You use it like below:
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h1.merge(h2) #=> {"a"=>100, "b"=>254, "c"=>300}
h1.merge(h2){|key, oldval, newval| newval - oldval}
#=> {"a"=>100, "b"=>54, "c"=>300}
h1 #=> {"a"=>100, "b"=>200}
I misunderstood the issue, it may be the same as itertools.chain in python. This worked for me ->
Enumerator::Chain.new(data_chained, data2)