Ruby | Range cover?() function Improve Improve Like Article Like Save Share Report The cover?() is an inbuilt method in Ruby returns a boolean value true if the given object lies within the given range, else it returns false. The object can be an element or a range. Syntax: range1.cover?(obj) Parameters: The function accepts an object which is to be checked for. Return Value: It returns a boolean value true if the given object lies within the given range, else it returns false. Example 1: # Ruby program for cover? method in Range # Initialize range range1 = (0..10) # Prints if lies or not puts range1.cover?(6) puts range1.cov</div>er?(13) Output: true false Example 2: # Ruby program for cover? method in Range # Initialize range range1 = (0..5) # Prints if lies or not puts range1.cover?((8)) puts range1.cover?((18)) Output: false false Last Updated : 18 Dec, 2019 Like Article Save Article Previous Ruby | abbrev function Next Ruby | Range end() function Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads Difference between Ruby and Ruby on Rails Ruby | Range exclude_end? function Ruby | Range eql?() function Ruby | Range each() function Ruby | Range entries() function Ruby | Range end() function Ruby | Range begin() function Ruby | Range inspect() function Ruby | Range include?() function Ruby | Range member? function Like gopaldave Follow Article Tags : Ruby Range-class Ruby-Methods Ruby