Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

array to hash ruby

# array = [["a", 1], ["b", 2], ["c", 3]]
array = [[:a, 1], [:b, 2], [:c, 3]]

# convert array to hash
hash = Hash[array]

puts hash

# Stdout/output:
# {:a=>1, :b=>2, :c=>3}
 
PREVIOUS NEXT
Tagged: #array #hash #ruby
ADD COMMENT
Topic
Name
2+8 =