Asked • 03/18/19

Checking if a variable is not nil and not zero in Ruby?

I am using the following code to check if a variable is not nil and not zero if(discount != nil && discount != 0) ... endIs there a better way to do this?

1 Expert Answer

By:

Wyatt G. answered • 12/24/20

Tutor
New to Wyzant

Software Engineer and Architect Specializing in Ruby on Rails

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.