Ruby Integer succ() function with example Last Updated : 03 Dec, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The succ function in Ruby returns the immediate successor of the number, i.e., it returns number + 1. If a float value is used, it throws an error message. Syntax: number.succ Parameter: The function takes the integer whose next is to be returned. Return Value: The function returns the immediate successor of the number, i.e., it returns number + 1 Example 1: Ruby # Ruby program for succ function # Initializing the numbers num1 = 100 num2 = 17 num3 = -90 num4 = -29 # Printing the next value puts num1.succ puts num2.succ puts num3.succ puts num4.succ Output: 101 18 -89 -28 Example 2: Ruby # Ruby program for succ function # Initializing the numbers num1 = 19 num2 = -17 num3 = -18 num4 = 16 # Printing the succ value puts num1.succ puts num2.succ puts num3.succ puts num4.succ Output: 20 -16 -17 17 Comment More infoAdvertise with us Next Article Ruby Integer to_i function with example G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads Ruby Integer size() function with example The size() function in Ruby returns the number of bytes in the machine representation of int. Syntax: number.size Parameter: The function takes the integer whose number of bytes is returned. Return Value: The function returns the number of bytes. Example #1: Ruby # Ruby program for size() function # 1 min read Ruby Integer to_s function with example The to_s function in Ruby returns a string containing the place-value representation of int with radix base (between 2 and 36). If no base is provided in the parameter then it assumes the base to be 10 and returns. Syntax: number.to_s(base) Parameter: The function takes the number and a base to whi 1 min read Ruby Integer to_r function with example The to_r function in Ruby converts the value of the number to a rational. Syntax: number.to_r Parameter: The function takes the number which is to be converted to a rational number. Return Value: The function returns the rational number. Example #1: Ruby # Ruby program for to_r function # Initializi 1 min read Ruby Integer to_f function with example The to_f function in Ruby converts the value of the number as a float. If it does not fit in float, then it returns infinity. Syntax: number.to_f Parameter: The function takes the integer which is to be converted to float. Return Value: The function returns the float value of the number. Example #1: 1 min read Ruby Integer to_i function with example The to_i function in Ruby converts the value of the number to int. If the number itself is an int, it returns self only. Syntax: number.to_i Parameter: The function takes the number which is to be converted to int. Return Value: The function returns the int value. Example #1: Ruby # Ruby program for 1 min read Ruby Integer truncate() function with example The truncate() function in Ruby returns an int truncated value to a precision of ndigits decimal digits. When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros. It returns itself when ndigits is zero or positive. The default value of ndigits is cons 1 min read Like