From: "Booker C.Bense" Date: 2006-10-13T23:40:32+09:00 Subject: Re: Silent out-of-index problems--how much of a problem are they really? -----BEGIN PGP SIGNED MESSAGE----- In article <452F174F.8070304@sbcglobal.net>, Kenneth McDonald wrote: > >So my question is, _in practice_, how difficult is it to track down >index-out-of-bounds-errors in Ruby? It can certainly be a godawful >problem in C, and I'm pretty sure it would be in Python, too, if >exceptions weren't thrown. And in Ruby, how does one track done where >such errors actually occur? In Python, I can simply look at the stack trace. > If you use the Ruby error handling methodology, it's generally pretty simple since nil has few methods. Most times if you're accessing an Array element you're going to do something with it, so the error crops up fairly immediately. Unfortunately, it does require this complicated setup %-). begin rescue => error print error.inspect end that and some introspective code in method_missing will go a long ways toward catching most runtime errors. I'm pretty sure you can get a full stack trace if you need it, but I've never needed it. _ Booker C. Bense -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQCVAwUBRS+kxGTWTAjn5N/lAQGe4gQAgLETOnvA3IukC0PYARa3lLZUacvOGGlE uZ5vFv5xF+fho2cwm55i3sQlEJlRr8YmdgAdA3MfMLbFi/rELIMywSM6aJeQkq61 PkuqG+Swj8Xzq8pWEEbiTT6Q7zTnOyC0Qm84TZTOzNixX4ulQ2h2Dp87aIkkHV1M mWhp6Fzg3Zg= =YuKL -----END PGP SIGNATURE-----