Not sure if this is a real Ruby method, but should be close enough:
hash = {} ['a', 'b'].each do |x| hash[x] = x.upcase end p hash
As a function, we would have this:
def theFunk(array) hash = {} array.each do |x| hash[x] = x.upcase end hash end p theFunk ['a', 'b', 'c'] # prints {"a"=>"A", "b"=>"B", "c"=>"C"}
Ismael Abreu Feb 24 2018-12-12T00: 00Z
source share