Link Details

Link 202024 thumbnail
User 1 avatar

By rick
via platypope.org
Published: Jul 11 2009 / 18:52

The Numeric#zero? method returns true if the number is 0 and false if it is not. The Numeric#nonzero? method returns nil if the number is 0 and the number itself if it is not.
  • 8
  • 9
  • 1633
  • 933

Comments

Add your comment
User 335891 avatar

onno.solin.eu replied ago:

0 votes Vote down Vote up Reply

"The Numeric#zero? method returns true if the number is 0 and false if it is not. The Numeric#nonzero? method returns nil if the number is 0 and the number itself if it is not."

Inconsistent maybe, but of no consequence when used in conditionals (where nil evaluates to false).

User 283967 avatar

rubayeet replied ago:

0 votes Vote down Vote up Reply

Waste of good two minutes.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.