From: progcat@... Date: 2007-04-18T12:10:10+09:00 Subject: Re: nil in evaluations Close but not really what I was looking for. example: if g(x) > f(x) then put "rejoice because f(x) is greater than f(x)" else put "g(x) <= f(x) OR g(x) and/or f(x) returned a nil so I wanted to execute this" end. In other words I want the function to work as it normally would for valid values, and if one or both are nil I want to make the test evaluate to false. Sorry I was not clear. Thanks, Tom On Apr 17, 9:42 pm, Prime wrote: > 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, prog...@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