this post was submitted on 09 Jul 2023
591 points (94.3% liked)

Programmer Humor

32721 readers
304 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@lemmy.world 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'.

[–] LeFrog@discuss.tchncs.de 4 points 1 year ago

a plural noun

sheep.each do |sheep|
  sheep.baaah
end

Oh shit :D

[–] FalseDiamond@sh.itjust.works 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.