Today I Learned

hashrocket A Hashrocket project

Splat hash values in ruby

In ruby, you might be familiar with the array splat syntax

values = [1,2,3]

more_values = [*values, 4] # [1,2,3,4]

But you can also do this with hashes

values = {a: 1, b: 2}

more_values = {**values, c: 3} # {a: 1, b: 2, c: 3}
See More #ruby TILs
Looking for help? Each developer at Hashrocket has years of experience working with Ruby applications of all types and sizes. We're an active presence at Ruby conferences, have written some of the most popular gems, and have worked on many of the web's Ruby on Rails success stories. Contact us today to talk about your Ruby project.