End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Integer#next
next
numeric.c
View on GitHub ↗
VALUE
rb_int_succ(VALUE num)
{
if (FIXNUM_P(num)) {
long i = FIX2LONG(num) + 1;
return LONG2NUM(i);
}
if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_plus(num, INT2FIX(1));
}
return num_funcall1(num, '+', INT2FIX(1));
}
Alias of #succ
Returns the successor integer of self (equivalent to self + 1):
Example
1.succ #=> 2 -1.succ #=> 0
Integer#next is an alias for Integer#succ.
Related: Integer#pred (predecessor value).