From: Robert Klemme Date: 2012-02-07T19:51:28+09:00 Subject: Re: NOT executing if statement On Mon, Feb 6, 2012 at 11:04 PM, Hasmukh Patel wrote: > Dave Aronson wrote in post #1044404: >> So what's the problem?  Are you trying to say that the function isn't >> doing *anything*, not even giving you back "Invalid Math Operation"? >> >> I can believe that it is at least giving you that, rather than doing >> the proper math.  Try checking the exact value of mathop.  Put quotes >> around it.  I think you'll discover you need one more operation.  This >> shouldn't be too big a challenge to sink your teeth into.  ;-) >> >> -Dave > > mathop=mathop.strip > This help Dave. Thanks for explanation You could have found it easier by relying on #inspect for debugging: def calc(x, y, mathop) printf "x=%p y=%p mathop=%p\n", x, y, mathop case mathop when '+' x + y when '-' x - y ... else raise "Invalid math operation #{mathop.inspect}" end end "case" also seems more appropriate here. And the name "sumtotal" is misleading. :-) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/