Converting Between Symbols and Strings


It says there that "create a variable called symbols, and store empty array on it," so I did follow that. Then on the second instruction, it says that "use .each to iterate over the strings array," Then on the third instruction, it says that "for each s in strings, use .to_sym to convert s to a symbol and use .push to add the new symbol in the symbols.

So, what I think of s is the strings stored in the strings array. So, I have to ask what is wrong about the code. It says that the "It looks like HTML isn't a symbol," and I also noticed it on the other arrays, it doesn't convert into a symbol.

Or, I misinterpreted the s in the instructions.

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

# Add your code below!

symbols = []

strings.each do |s|


String.to_sym is not an in-place method. Either assign the new value to a variable, or pass it directly to the push() method.


you have to use symbols.push(s.to_sym) like mtf suggests. I have no clue how this works lol.

Would you mind expanding on how .to_sym works when passed directly into push, and not stand alone like OP used?


String.to_sym is not an in-place method, as we stated earlier. To preserve its effect we need to assign it.

symbol = s.to_sym

Now symbol is the cached value.

Array.push() takes an object and inserts it at end of the array (appends it).


takes the output of the method and assigns it directly to the array, the same as,


given the above cached value.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.