CHAPTER 4. CONTAINERS, BLOCKS, AND ITERATORS
PAGE 44
a = [ 1, 3, 5, 7, 9]
a[-1] -> 9
a[-2] -> 7
a[-99] -> nil
On topics occasionally germane to software development.
CHAPTER 4. CONTAINERS, BLOCKS, AND ITERATORS
PAGE 44
a = [ 1, 3, 5, 7, 9]
a[-1] -> 9
a[-2] -> 7
a[-99] -> nil

My name is Matt Blodgett. I'm 6'7", obsessed with independent music, a vegetarian, and a software engineer. I live in Grand Rapids, Michigan.
Copyright © 2009 Matt Blodgett . Blog Designed by Dante Araujo & Deluxe Templates.
3 comments:
Perhaps I am missing something - why does that make you sigh longingly. Is it the banality of the example?
No, that's not the case at all.
Coming from a C#/Java/C background, I'm trying to highlight features I've discovered in Ruby that make me long for it.
Ahh... that makes sense. I'm a bit like that with C and Python.
BTW, these examples give identical results in Python except for 'a[-99]' which raises an IndexError exception. I can see advantages to both approaches and both are better than a program crash!
Post a Comment