The key


Why could we use these symbols a, s en the word key as a key?

strings = ["HTML", "CSS", "JavaScript", "Python", "Ruby"]
symbols = []

strings.each do |s|

This also works.

strings = ["HTML", "CSS", "JavaScript", "Python", "Ruby"]
symbols = []

strings.each do |key|

And actually we do not really need to convert strings to symbols. As long as the string is short.


I don't understand your question.

It's an array here, not a hash, we don't use any key.


You are right for now but for later on?


What about later on?

s and key in your examples are not used as keys, they are used as variables (variables which don't represent keys either, they represent values).


Ok thanks. So it is only the array of strings we'd like to later use as hash keys.


We could, but then we would need a hash, not an array.