13
olezhka
7y

I just love languages and functions that support using a negative int to access array from the end! Awesome.

Comments
  • 0
    ...Never thought of that, but it seems really smart!
  • 1
    Yep that is really cool.
    Another cool thing I've seen is negative into returning everything but the value.
    So arr[-5] would give you all values but the one at index 5. R does that with vectors for example
  • 0
    you might want to take a look at python
    and list slices
    they're awesome
  • 0
    A big problem that comes to mind with this is that you could do it by accident and don't get an OutOfRangeException or similar
  • 0
    @kaesaecracker not a big problem, man. Sacrificing runtime exception for a powerful feature? I'll take that every day, thank you very much :)
Add Comment