P
progcat
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
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