Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

ruby
math
communitycreator

What is num.odd? in Ruby?

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The num.odd? function in Ruby returns true if the integer is odd; otherwise, it returns false.

Figure 1 shows the visual representation of the num.odd? function.

Figure 1: Visual representation of the num.odd? function

Syntax

num.odd?
# where num is the integer which is to be checked for odd 

Parameter

This function does not require a parameter.

Return value

This function returns true if the integer is odd; otherwise, it returns false.

Example

#odd number
print "(3).odd? : ",(3).odd? , "\n"
#even number
print "(4).odd? : ", (4).odd?, "\n"

RELATED TAGS

ruby
math
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring