6

To the people that mistake i and j in nested loops: Have you considered giving these different names?

Comments
  • 6
    like k and l? Great idea! I've never thought of that.

    Thanks!
  • 1
    @netikras Anything not similar at least, yes.
  • 6
    It's been awhile since I've written a for loop. I've sort of arrived a point where if I have occasion to use one, it's because I'm probably not processing my data properly.
  • 2
    There's also the option to use a font that gives these a different look.
  • 4
    Foreach() anyone?

    I rarely stumble upon a need to use for loops anymore, unless I need to track index/keys
  • 1
    What the fuck is a loop nigga just (0 to 10).zip(0 to 10), dont be a fucking cretin, a mumbling idiot, a fool.
  • 0
    Wait what, those can be renamed?
  • 4
    Always preferred i and !
  • 0
    when i need a nested loop im prob doing something wrong... or math at which point i made a mistake already anyways
  • 1
    @C0D4 @kleopi Grid operations?
  • 2
    @Lor-inc if they cant be avoided by streams or matrix-calculations, yeah probably. in that case i use x y z as variables usually, or row column
  • 1
    I once worked on a codebase that had i and j as fields as well as local variables used in said loops, and they were being used to hold the values of (local) i and j at various weird points.

    Could've written a programming puzzles book with that guy's code.
  • 3
    use "I" and "l" for more clarity
    (capital i and lower case L)

    it's even funnier when using "or" statements

    if I || l:
    print("much clear")
  • 0
    @kescherRant no way!!! i and j in programming are the same as Alice and Me in networks :/
  • 0
    @SortOfTested depends on the language, doesn't it?
  • 1
    @Emphiliis
    Not really, no :)
  • 1
    bold of you to assume that I wouldn't fuck up just as bad with clear variable names.
  • 1
    @Lor-inc
    Rows/columns instead of i / j

    Keeps things legible.
Add Comment