From: Sean Chittenden Date: 2002-07-09T17:17:40+09:00 Subject: Re: for ... else ... end > |And by the way, the Pythonism originally referenced is > |certainly more elegant than the throw/catch example. I > |wonder if it's useful enough to consider including? > | > |Maybe it's one of those things you don't realize you need > |until you have it. > > But I don't feel "for .. else" is intuitive. The "else" seem like > indentation mistake rather than loop termination hook. Maybe there > can be a more suitable keyword. Hmm... I work around not having this construct constantly when doing database work. After talking with Holden about this on IRC, I think the following examples are helpful. dbh.select_all(sql) do |row| # do something with row else puts "No rows returned!" end for elt in arr puts elt else puts "No rows processed" end Which opens the door for: for elt in arr puts elt else puts "no rows" ensure puts "done looping" end Hmm... I think else is the correct word because it is short hand for typing out: if [].length > 0 for elt in [] puts elt end else puts "now rows" end puts "done looping" The example immediately above strikes me as a way of working around the language, as opposed to the language doing what you want it to. ::shrug:: My $0.02. -sc -- Sean Chittenden