Flowdock
method

rationalize

Importance_1
Ruby latest stable (v2_5_5) - 0 notes - Class: Complex
rationalize(p1 = v1) public

Returns the value as a rational if possible (the imaginary part should be exactly zero).

Complex(1.0/3, 0).rationalize  #=> (1/3)
Complex(1, 0.0).rationalize    # RangeError
Complex(1, 2).rationalize      # RangeError

See to_r.

Show source
Register or log in to add new notes.