News for hackers. Stuff that matters.
Re:Experiences Using Go as a Teaching Language with Young Pr... by infogulch on Thursday August 13, 2015 @11:36PM (#10058507)
Slicing is free and can be done inline, so your first and third examples can be changed to the range syntax:

    // iterate half the stack:
    for i := range slice[:len(slice)/2] {}
    
    // iterate from a different starting position:
    for i := range slice[5:] {}
That still leaves stepping and reverse, but I've found those are relatively rare, especially compared to the other two.
Re:Experiences Using Go as a Teaching Language with Young Pr... by laumars on Tuesday August 18, 2015 @04:08AM (#10078037)
Ooops, just seen this comment. Yes, you're right, your slice techniques do make a lot more sense than my examples.