How to conevert an array to hashes

hi,

i would like to know about if any method available in ruby to convert
the array into a hash in ruby

with regards,
anoob bava

a=[[‘1’,2],[‘2’,5]]

puts a.to_h

output

{“1”=>2, “2”=>5}

Hash[1,2,3,4]
=> {1=>2, 3=>4}

a= [1,2,3,4]
Hash(*a)
=> {1=>2, 3=>4}

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs