Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Float#-

self - other → numeric

Returns a new Float which is the difference of self and other:

Example
f = 3.14
f - 1                 # => 2.14
f - 1.0               # => 2.14
f - Rational(1, 1)    # => 2.14
f - Complex(1, 0)     # => (2.14+0i)
See also #+ #-@ #** #/ also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0