you are viewing a single comment's thread
view the rest of the comments
[–] -1 points 3 years ago* (last edited 3 years ago) (2 children)

First time I’ve ever heard someone call a for loop “weird“. They’ve been around for 50 years 😂

The whole point was on readability, not trying to make rubocop be quiet. Sure, .each is great, but I’m not sure about it being shorthand. What did you save? Like 3 characters? I find the for loop more readable unless I’m method chaining.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 3 years ago* (1 child)

    Not in ruby, the for loop was initially put there to make it friendly for people from other languages and is discouraged. It's just syntax sugar on top of each.

    By shortand version I meant

    array.each(&:to_s)
    

    (although in this case I'm not calling puts anymore)

    edit: lemmy keeps putting the & there, but you know what I mean

  • source
  • parent
  • hideshow 1 child comment