On Dec 22, 2009, at 5:30 PM, Seebs wrote: > But that doesn't help you in the case where you want to replace empty strings > with '-'. For that, maybe something like: > > x = (x && !x.empty?) ? x : '-' > > (That assumes x has an empty? predicate, not everything does.) I've always found the easiest way to replace empty strings is: x = '-' if x.to_s.empty? Just about everything has a #to_s method, and nil evaluates to an empty string, so this will replace x if it is either an empty string *or* if it is nil *or* if x is currently not yet defined. Cheers,