Rational(x[, y]) â numeric
Instance Public methods
Returns x/y;
1 2 3 4 | Rational( 1 , 2 ) #=> (1/2) Rational( '1/2' ) #=> (1/2) Rational( nil ) #=> TypeError Rational( 1 , nil ) #=> TypeError |
Syntax of string form:
1 2 3 4 5 6 7 8 9 10 11 | string form = extra spaces , rational , extra spaces ; rational = [ sign ] , unsigned rational ; unsigned rational = numerator | numerator , "/" , denominator ; numerator = integer part | fractional part | integer part , fractional part ; denominator = digits ; integer part = digits ; fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ; sign = "-" | "+" ; digits = digit , { digit | "_" , digit } ; digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; extra spaces = ? \s* ? ; |
See String#to_r.
Please login to continue.