this post was submitted on 09 Jul 2023
610 points (93.8% liked)

Programmer Humor

32710 readers
103 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
[–] atimholt 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

[–] [email protected] 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.