What is the integer.numerator property in Ruby?
Overview
In Ruby, the numerator property of an integer is used to get the numerator of an integer value.
Syntax
intValue.numerator
Return value
This property returns the integer itself.
Example
# create integer valuesint1 = 20int2 = 4int3 = 34int4 = -3# get the numeratorputs int1.numeratorputs int2.numeratorputs int3.numeratorputs int4.numerator
Explanation
- Line 2–5: We create some integer values.
- Line 8–11: We use the
numeratorproperty to get the numerator of the integer values. Next, we print the output.