The Array#each method [1] allows you to do something with each member of strings, and the String#to_sym [2] method allows you to create a symbol from a string. So roughly:
make a new array called symbols
for each entry in strings, create a corresponding symbol, and put it in your new symbols array.
The Array#each method [1] allows you to do something with each member of strings, and the String#to_sym [2] method allows you to create a symbol from a string. So roughly:
make a new array called symbols
for each entry in strings, create a corresponding symbol, and put it in your new symbols array.
On 25/02/14 16:16, Mei Chen wrote:
Hi All,
I'm taking programming lessons on Code academy, and I am stuck on the
symbols lesson.
The instructions say :
We have an array of strings we'd like to later use as hash keys, but
we'd rather they be symbols.
Create a new array, symbols.
Use .each to iterate over the strings array and convert each string to a
symbol, adding those symbols to symbols.