mastermind@lemm.ee to Programmer Humor@lemmy.ml · 2 years agowhy not a,b or x,y?lemm.eeimagemessage-square84linkfedilinkarrow-up1635
arrow-up1592imagewhy not a,b or x,y?lemm.eemastermind@lemm.ee to Programmer Humor@lemmy.ml · 2 years agomessage-square84linkfedilink
minus-squareatimholt@lemmy.worldlinkfedilinkarrow-up6·2 years agoI 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’.
minus-squareLeFrog@discuss.tchncs.delinkfedilinkarrow-up3·2 years ago a plural noun sheep.each do |sheep| sheep.baaah end Oh shit :D
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’.
sheep.each do |sheep| sheep.baaah end
Oh shit :D