Ruby Float coerce() method with example Last Updated : 08 Jan, 2020 Comments Improve Suggest changes Like Article Like Report coerce() is a float class method which return the ceil value of the passed float value. Syntax: float.coerce() Parameter: numeric values (can be integer as well as float value) Return: An array with both float and numeric value represented in the form of Float objects. Example #1 : Ruby # Ruby code for coerce() method # ceil value of the float value puts "coerce example 1 : #{2.5.coerce(1.1)}\n\n" # ceil value of the float value puts "coerce example 2 : #{2.11115.coerce(22221)}\n\n" Output : coerce example 1 : [1.1, 2.5] coerce example 2 : [22221.0, 2.11115] Example #2 : Ruby # Ruby code for coerce() method # ceil value of the float value puts "coerce example 1 : #{2.00.coerce(1.1)}\n\n" # ceil value of the float value puts "coerce example 2 : #{-333333.coerce(2.21)}\n\n" Output : coerce example 1 : [1.1, 2.0] coerce example 2 : [2.21, -333333.0] Comment More infoAdvertise with us Next Article Ruby Float coerce() method with example M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Float-class Similar Reads Ruby Integer chr function with example 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 don 1 min read Ruby Integer modulo() function with example The modulo function in Ruby returns the modulo value of a number by another number. Syntax: number1.modulo(number2) Parameter: The function takes number1 and number2 whose modulo is returned. Return Value: The function returns the modulo value of a number by another number. Example #1: Ruby # Rub 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 | String casecmp Method casecmp is a String class method in Ruby which is Case-insensitive version of String#<=>. For now, case-insensitivity only works on characters A-Z/a-z, not all of the Unicode characters. This method is different from casecmp! method. Syntax: str.casecmp(other_str) Parameters: Here, str is the 1 min read Ruby | String casecmp? Method casecmp? is a String class method in Ruby which is used to return true if both the string are equal after Unicode case folding and false if they are not equal. Syntax: str.casecmp?(other_str) Parameters: Here, str is the given string to be checked and other_str is the string to which str is compared 1 min read Like