Is it possible to write the action in two steps


That's great and elegant. But (out of curiosity) is it possible to write the action in two steps, like this:

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

symbols = []

strings.each do |s| s.to_sym; symbols.push(s)

print symbols

I get the following print out:

["HTML", "CSS", "JavaScript", "Python", "Ruby"]nil

but with this error message "Oops, try again. It looks like HTML isn't a symbol." Anyone know why this is the case?

9 Converting Between Symbols and Strings

This is not an in-place mutation. The above is only a representation that needs to be assigned, hence,



Hello sir. I have not heard that term "in-place mutation" so far I believe. I am confused because I thought sprazzeus code would work to I am just wondering why. That method has always seemed to work before.


in-place means to write the change back onto itself. Akin to,

s = s.to_sym

Consider string.capitalize...

s = s.capitalize

can be written as,


Note the !.


A post was split to a new topic: Symbols.push(s)