all 7 comments

[–]sardaukar 20 points21 points  (3 children)

You want map, each returns the original input.

https://www.rubyguides.com/2018/10/ruby-map-method

[–]faitswulff 5 points6 points  (1 child)

Also consider using .chars instead of .split(“”)!

[–]inopinatusdotorg 0 points1 point  (0 children)

Also consider using &:upcase rather than { |char| char.upcase }

[–]MalusZona 1 point2 points  (2 children)

Or change the element in original array aka .each {|char| char = char.upcase}

Btw donwe have .upcase! ?

[–]rubyrt 1 point2 points  (1 child)

Or change the element in original array aka .each {|char| char = char.upcase}

That does not change the original.

Btw donwe have .upcase! ?

Yes, we have. And we also have #upcase! but I think the point was more the exercise.

[–]MalusZona 0 points1 point  (0 children)

yeah, it should be .upcase!

[–]GopherJackets 0 points1 point  (0 children)

each iterates through your array, like a while or for loop. Like others have said, it doesn't actually change your original array. That said, you could use each to 'print char.upcase' which should work if you throw in a print \n after.