Hacker News new | ask | show | jobs
by everybodyknows 862 days ago
Interestingly, this does not raise any error, rather has no effect.

for i := range -10 { panic(i) }

2 comments

"yes, please run this loop minus 10 times" - statements dreamed up by the utterly Deranged
Back in my days, you had to do it this way

for i := 0; i <=-10; i++{

  panic

}
Back in my day you would do

    for (size_t i = 0; i < -10; i++) {
        panic
    }
And it would panic 18446744073709551606 times.
Sure, presumably for the same reason a C-style for loop wouldn't do anything weird there either.