--0NB0lE7sNnW8+0qW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2006.10.13 09:11, Kenneth McDonald wrote: > I'm slowly doing more in Ruby (in addition to what I do in Python), as I > like the cleanliness of the language. However, one thing that I really > _don't_ like is the fact that an attempt to access a non-existent list > item silently returns nil, rather than throwing an exception. Is there a > way to make this more strict? Hashes have the same behavior, but since > they can be assigned a default block, that isn't nearly so much of a > problem. > > I know I could change List behavior, but there are very obvious reasons > why that's a Bad Thing. I could also subclass list, but then I miss all > of the syntactic niceties of lists. And both solutions impose an extra > level of calling for what will be very frequent actions. > > Any thoughts welcome, Since you asked.. :) We have managed to make do without Array access raising exceptions. I would REALLY recommend leaving behind the baggage of any previous languages and take a head-first plunge. In Ruby, Array access returns a nil if the index is not found. Embrace it! Form your code around the Ruby idioms, not the other way around! The payoff will be much greater. --0NB0lE7sNnW8+0qW Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFLxST7Nh7RM4TrhIRAjpEAKCQekkcNy/tTJzz3MxSz4kkugUdpQCeMPmc kkOnmdXhHvQisA5lAw49GpA ¨Â-----END PGP SIGNATURE----- --0NB0lE7sNnW8+0qW--