As I learned, I found a difference in how to implement hashes, so I will summarize it.
test.rb
#How to write a string with a key
test{"subject" => "Math" , "score" => 60}
#How to write a symbol with a key
test1{:subject => "Math" , :score => 60}
#How to write a symbol with a key(Abbreviated system)
test2{subject: "Math" , score: 60}
#Each output method
puts test["subject"]
puts test1[:subject]
puts test2[:subject]
When executed, all the same values were output. Every time I learn, I will post it. .. ..
Recommended Posts