Ruby Integer chr function with example Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The chr function in Ruby returns the string containing the character represented by the int's value according to encoding. Syntax: string.chr([encoding]) Parameter: The function takes the integer value whose encoding is to be done. It takes a non-mandatory parameter encoding if encoding is to be done according to that. Return Value: The function returns character. Example #1: Ruby # Ruby Program of Integer chr function # Initializing the numbers num1 = 65 num2 = 66 num3 = 97 num4 = 245 # Prints the chr # after encoding puts num1.chr puts num2.chr puts num3.chr puts num4.chr(Encoding::UTF_8) Output: A B a õ Example #2: Ruby # Ruby Program of Integer chr function # Initializing the numbers num1 = 119 num2 = 68 num3 = 89 num4 = 255 # Prints the chr # after encoding puts num1.chr puts num2.chr(Encoding::UTF_8) puts num3.chr puts num4.chr(Encoding::UTF_8) Output: w D Y ÿ Comment More infoAdvertise with us Next Article Ruby Integer chr function with example G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads Ruby Integer div() function with example The div() function in Ruby returns the integer division of two numbers. Syntax: (number1).div(number2) Parameter: The function needs two numbers number1 and number2, where number1 is the dividend and number2 is the divisor. Return Value: The function returns the integer division of two numbers. Exam 1 min read Ruby Integer abs() function with example The abs() function in Ruby returns the absolute value of the integer. Syntax: (number).abs Parameter: The function takes the integer whose absolute value is to be returned. Return Value: The function returns the absolute value of the integer. Example #1: Ruby # Ruby program Integer abs() function # 1 min read Ruby Integer even? function with example The even? function in Ruby returns a boolean value. It returns true if the number is even, else it returns false. Syntax: number.even? Parameter: The function takes the integer which is to be checked for even or not. Return Value: The function returns a boolean value which determines if the value is 1 min read Ruby Integer gcd() function with example The gcd() function in Ruby returns the gcd of two numbers. GCD signifies the greatest common divisor which divides both the numbers. Syntax: number1.gcd(number2) Parameter: The function requires two numbers whose gcd is to be returned. Return Value: The function returns the gcd of two numbers Exampl 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 Like