From: Randy Lawrence Date: 2004-07-03T03:29:07+09:00 Subject: Re: How to detect if variable has been defined yet? Sean O'Dell wrote: > On Friday 02 July 2004 10:49, Randy Lawrence wrote: > >>Hi, >> >>I'd like to detect if a variable has been defined yet. Is this possible >>in Ruby or mod_ruby? >> >>For example, I'd like to do the following: >> >>if $total.exists >> $total = $total + 1 >>else >> $total = 0 >>end > > > if defined?($total) > $total = $total + 1 > else > $total = 0 > end > > > Sean O'Dell > > Thanks! This was exactly what was needed and it works.