From: Chad Perrin Date: 2007-07-19T14:03:40+09:00 Subject: Re: The Pebble in the Ruby Shoe On Thu, Jul 19, 2007 at 01:43:36PM +0900, Sy Ali wrote: > On 7/18/07, Phlip wrote: > >Imagine a language that used 1-based indexing. It would make working in > >0-based appallingly hard even for simple situations. So we would prefer > >this > >slippery slope to slide in the correct direction. > > I'm a very young programmer, and I've known about this 0 vs 1 issue > for a while now. Phlip's comment above is very good at explaining the > reason behind it, but I've had a hard time truly grasping it. > > Is anyone willing to show some snippets of Ruby code which could > demonstrate the challenge of working with 1-based arrays? There were > some snippets in previous messages but they were too partial for me to > really understand things.. > irb irb(main):001:0> foo = %w[zero one two three] => ["zero", "one", "two", "three"] irb(main):002:0> puts "last element: #{foo[-1]}" last element: three => nil -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] John Kenneth Galbraith: "If all else fails, immortality can always be assured through spectacular error."