From: Prime@... Date: 2007-04-18T11:45:06+09:00 Subject: Re: nil in evaluations I am not sure this is what you wanted but, if g(x).nil? || f(x).nil? p "nil found" else p "no nil" end can be used to evaluate if the function equals nil On 2007-04-17 19:08:05 -0700, progcat@comcast.net said: > > > Problem: I have functions that sometimes evaluate to nil and cause my > program to crash in comparisons, etc. > > For example g(x) and f(x) either could be nill in the following: > if g(x) > f(x) > p "not reached" > else > p "also not reached but I want it to reach here if either fuction > returns nil" > end > > What can I do to make any comparison that has nil in it to evaluate to > false? I have seen operator overloading and class definitions in > ruby, so I imagine this would be quite simple. > > (I know I can set g(x) and f(x) to variables before the if statement, > but I really want to avoid that) > > Thanks in advance, > Tom