Confusion about the ".push" function

Hi folks, I have recently come across an issue when using the “.push” funtion. As shown below, the upper part is the correct coding while the lower part is the coding I have written. I just have no idea why the coding of mine cannot show the result of [:HTML, :CSS, :JavaScript, :Python, :Ruby]. Instead, it just shows [“HTML”, “CSS”, “JavaScript”, “Python”, “Ruby”]. Please kindly help if anyone knows where’s the issue, thanks a lot:)

correct coding:
strings = [“HTML”, “CSS”, “JavaScript”, “Python”, “Ruby”]

symbols =[
]

strings.each {|s|

symbols.push (s.to_sym)

}

print symbols

My incorrect coding:
strings = [“HTML”, “CSS”, “JavaScript”, “Python”, “Ruby”]

symbols =[
]

strings.each {|s|

s.to_sym

symbols.push (s)

}

print symbols

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