3 ms·
I hadn't seen these cartoons before. I had a good laugh :) More seriously: there are very limited cases where indexing explicitly into an array using literals
by nur0n 8y ago
I hadn't seen these cartoons before. I had a good laugh :)
More seriously: there are very limited cases where indexing explicitly into an array using literals is The Right Thing to do. It's almost always better to use `map(fn, xs)`, `foreach(fn, xs)`, `for x in xs; fn(x); end`, ... .
If you really wanted to, you can even do:
for i in firstindex(xs):lastindex(xs)
x = xs[i]
end