I have an issue in understanding the syntax for adding to a hash .
In night at the movies we use the following code to do so
movies[title.to_sym] = rating.to_i
On the right side of the equation Tthe idea of adding the title to the hash as a symbol makes sense to me, but why do we make this equal to rating? I can’t make any sense of this.
That’s not an equation, it’s an instruction, it carries out an action. A hash is a data structure that stores key-value pairs, just like a phone book (name-number pairs)
Also, one shouldn’t internalize user input into symbols, instead one should use frozen strings as keys
(symbols should be used in finite amounts, typically only mentioned directly in code, not dynamically generated)