Use of .push and .to_sym


#1

i do not understand properly
please explain what is it doing because output is same nothing is change here

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

strings.each do |s| 
 symbols.push(s.to_sym)
end 
print symbols

output
[:HTML, :CSS, :JavaScript, :Python, :Ruby]


#2

you convert strings to symbols, "html" (string) has become :HTML (symbol). same for all the other elements in the array

so there is certainly a change.


#3

thanks for your help

now i understand


#4

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