From: "David A. Black" Date: 2004-09-19T08:22:02+09:00 Subject: Re: Method improvement request .-- Hi -- On Sun, 19 Sep 2004, Bill Guindon wrote: > On Sun, 19 Sep 2004 06:29:43 +0900, Charles Hixson > wrote: > > > yield a if a and a.length > 0 > > this can be written as... > yield a if a unless a.empty? Or: yield a unless a.to_s.empty? # nil.to_s is "" (However, see my notes in my other post.) > it won't get to the 'unless' if 'a' is nil, so it dodges the missing > method error. > > > return "" unless chunk.respond_to?("[]") > > you can avoid this by forcing the issue... > chunk = [] << chunk Or: chunk = [chunk] (I personally dislike reusing variable names when things are changed like this, but that's a side [non-]issue :-) David -- David A. Black dblack@wobblini.net