----- Original Message ----- From: "Pit Capitain" <pit / capitain.de> > > I've done that, for instance, in my dbdbd (database definer) program. > > It uses 1-originating array notation to index columns, but can also > > use field-names. So the reader method for the sort_key (for example) > > is: > > > > def sort_key > > @sort_key - 1 > > rescue NameError > > @sort_key > > end > > When you announced dbdbd I quickly browsed through the code. I > had the impression that I understood your well written program - > besides this very example. I really tried to understand what's going > on, but I just couldn't get it. > > > which I think looks better than: > > > > def sort_key > > if @sort_key.respond_to?(:-) > > @sort_key - 1 > > else > > @sort_key > > end > > end > > Ok. With this alternative code and the remarks in your mail I finally > understand what you did. But for me the most intention revealing > implementation would simply be: > > def sort_key > if @sort_key.is_a? Integer > @sort_key - 1 > else > @sort_key > end > end Dave's method: use :-, catch exception Pit's method: use :- if key is_a Integer Gavin's method: use :- if (key - 1) is_a Integer :) Ruby: so much flexibility == so many choices So many choices == difficulty in making wise and consistent decisions Static languages tend to make some of these decisions for you. They are uninspiring, but the seatbelts are sometimes comfortable. Java is a language suited for dummies. I don't think we'll see Ruby fit that mould, even though its simplicity and flexibility makes it, IMO, the perfect language for teaching. > Regards, > Pit Gavin