How to push an array into a hash in ruby -
i didn't find in internet answers question.
i have hash follows:
hash = {[1111, 4, 20]} and want push array ([3333, 2, 70]) hash like:
hash = {[1111, 4, 20], [3333, 2, 70]} how can achieve ?
thanks!
what you're trying have here not hash. it's array of arrays. syntax wrote not valid ruby syntax.
to add item array use <<.
for example:
array = [[1111, 4, 20]] to add item do:
array << [3333, 2, 70] your array be:
[[1111, 4, 20], [3333, 2, 70]]
Comments
Post a Comment