Hi, I’m learning ruby/rails and
I don’t understand the difference between map and each in the below examples. Specifically, why each doesn’t work.
irb(main):152:0> %w[a b c].each { |char| char.upcase }
=> ["a", "b", "c"]
irb(main):153:0> %w[a b c].map { |char| char.upcase }
=> ["A", "B", "C"]
I could ignore it but it’s bothering me and I think it might be fundamental later on.
I tried googling it but the hits I found on the differences used examples I didn’t understand and were over my head.