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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -