Confused about how to convert strings to hashes, asking for help


The method .to_sym doesn't appear to work for me. I even checked the glossary first and the first to find proper syntax, but i can't figure it out. I've tried dozens of different syntax and I can't seem to get the string to convert into symbols let alone getting the new symbols into the new array.

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

strings.each do |x|
  print x.to_sym 


Rather than print, use Ruby's array.push() method to append these to the symbols array.


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