From: wannes Date: 2005-04-22T23:09:42+09:00 Subject: Re: for .. in .. else? Adam Keys wrote: > Maybe I missed something, but when I extracted this code and ran it in > irb, it didn't work like I thought it would: > > irb(main):087:0> songs > => ["Rocky Raccoon", "As My Guitar Gently Weeps", "She Came In Through > The Bathroom Window"] > irb(main):088:0> unless songs.each do |song| > irb(main):089:2* p song > irb(main):090:2> end.empty? > irb(main):091:1> p 'no songs!' > irb(main):092:1> end > "Rocky Raccoon" > "As My Guitar Gently Weeps" > "She Came In Through The Bathroom Window" > "no songs!" > => nil > irb(main):093:0> > > The presence of 'no songs!' is not what I'd expected. The presence if 'no songs!' is perfectly normal ;) The (not so) subtile difference between unless and if. unless songs.empty? do p "there are songs" end if songs.empty? do p "no songs'" end grtz, wannes