Symbols are used a lot for method arguments.
Later we will see more usage of it.
Also, as we discussed earlier, symbols are frequently used as hash keys.
In the case provided above, we used the string age twice.
It means Ruby had to create two strings with the same value.
Creating more strings take more memories.
In the case given above, as you already know, symbols are used as keys instead of strings.
It means once the symbol :age
was created then the same symbol
is used when the value is retrieved. For the whole operation
only once :age
symbol was created and it helps save memory.