From: Lyle Johnson Date: 2004-01-27T01:34:54+09:00 Subject: Re: Print empty values to a file? Qubert wrote: > So I am trying to figure out a cleaver means to check if each value > exists or nil then 'puts "nil"' so there are no more blanks. > I can do this the brute force method, with if/then statements > everywhere, but I was wondering if there is a Ruby way to accomplish > this. OK, this is very evil, but you could redefine the to_s() method for NilClass at the top of your script, e.g. class NilClass def to_s "nil" end end Now when you do a puts() on nil, it will print the literal string "nil" instead of the empty string. Hope this helps, Lyle