• atimholt@lemmy.world
    link
    fedilink
    arrow-up
    7
    ·
    1 year ago

    I like range-based for loops. You can just name the iterator after the object that it actually is. Have to be a little careful though, if the container is named a plural noun, and the natural name is the same word minus the easy-to-miss ‘s’.

    • LeFrog
      link
      fedilink
      arrow-up
      4
      ·
      1 year ago

      a plural noun

      sheep.each do |sheep|
        sheep.baaah
      end
      

      Oh shit :D