defined?
associated with amount ? amount : r(1,4)
amount ? amount : r(1,4)
, therefore it is equivalent to:
defined?(amount ? amount : r(1,4))
You probably want:
defined?(amount) ? amount : r(1,4)
Actually, the probability that amount || r(1,4)
amount || r(1,4)
or amount.nil? ? r(1,4) : amount
amount.nil? ? r(1,4) : amount
amount.nil? ? r(1,4) : amount
will be better suited to what you want, since I think you don't want this:
1.9.3p194: 001> defined? (Amount)
=> nil
1.9.3p194: 002> amount = nil
=> nil
1.9.3p194: 003> defined? (Amount)
=> "local-variable"
... in this case, @c
will be nil
- the value of a particular variable.
source share