Ruby Integer next function with example Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The next 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.next 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 of next function # Initializing the numbers num1 = 100 num2 = 17 num3 = -90 num4 = -29 # Printing the modulo value puts num1.next puts num2.next puts num3.next puts num4.next Output: 101 18 -89 -28 Example #2: Ruby # Ruby program of next function # Initializing the numbers num1 = 19 num2 = -17 num3 = -18 num4 = 16 # Printing the modulo value puts num1.next puts num2.next puts num3.next puts num4.next Output: 20 -16 -17 17 Comment More infoAdvertise with us Next Article Ruby Integer next function with example G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads Ruby Integer pred() function with example The pred function in Ruby returns the immediate predecessor of the number, i.e., it returns number - 1. If a float value is used, it throws an error message. Syntax: number.pred Parameter: The function takes the integer whose predecessor is to be returned. Return Value: The function returns the imme 1 min read Ruby Integer odd? function with example The odd? function in Ruby returns a boolean value. It returns true if the number is odd, else it returns false. Syntax: number.odd? Parameter: The function takes the integer which is to be checked for odd or not. Return Value: The function returns a boolean value which determines if the value is odd 1 min read Ruby Integer integer? function with example The integer? function in Ruby returns a boolean value. It returns true if the number is an int, else it returns false. Syntax: number.integer? Parameter: The function takes the integer which is to be checked for int or not. Return Value: The function returns a boolean value which determines if the v 1 min read Ruby Integer lcm() function with example The lcm() function in Ruby returns the lcm of two numbers. LCM signifies the lowest common multiple which is divisible by both the numbers. Syntax: number1.lcm(number2) Parameter: The function requires two numbers whose lcm is returned. Return Value: The function returns the lcm of two numbers Examp 1 min read Ruby Integer prime? function with example The prime? function in Ruby returns a boolean value. It returns true if the number is prime, else it returns false. It requires the 'prime' class to be pre-added. Syntax: number.prime? Parameter: The function takes the integer which is to be checked for prime or not. Return Value: The function ret 1 min read Like