Skip to content
instance method

Integer#+

(::BigDecimal) -> ::BigDecimal
(::Integer) -> ::Integer
(::Float) -> ::Float
(::Rational) -> ::Rational
(::Complex) -> ::Complex
self + other → numeric

Returns the sum of self and other:

Example
1 + 1               # => 2
1 + -1             # => 0
1 + 0              # => 1
1 + -2             # => -1
1 + Complex(1, 0)  # => (2+0i)
1 + Rational(1, 1) # => (2/1)

For a computation involving Floats, the result may be inexact (see Float#+):

Example
1 + 3.14           # => 4.140000000000001
See also #** #- #* #-@ also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0