this post was submitted on 09 Jul 2023
614 points (93.9% liked)

Programmer Humor

31812 readers
598 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 7 points 1 year ago (2 children)

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'.

[–] [email protected] 4 points 1 year ago

a plural noun

sheep.each do |sheep|
  sheep.baaah
end

Oh shit :D

[–] FalseDiamond 1 points 1 year ago

This is one of the few things I really like about JS/TS. for (thing of things) is very legible and self documenting.