Ruby | Range member? function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The member?() is an inbuilt method in Ruby returns a boolean value true if the given object lies within the given range, else it returns false. Syntax: range1.member?(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 # Ruby program for member? method in Range # Initialize range range1 = (0..10) # Prints if lies or not puts range1.member?(6) puts range1.member?(13) Output: true false Example 2: Ruby # Ruby program for member? method in Range # Initialize range range1 = (2..15) # Prints if lies or not puts range1.member?(6) puts range1.member?(13) Output: true true Comment More infoAdvertise with us Next Article Ruby | Range last() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Range-class Similar Reads Ruby | Range new() function The new() is an inbuilt method in Ruby returns a new range of numbers. Syntax: range1.new(first, last) Parameters: The function accepts first and last which is the range that is to be created. Return Value: It returns the range of numbers. Example 1: Ruby # Ruby program for new() # method in Range # 1 min read Ruby | Range hash() function The hash() is an inbuilt method in Ruby returns a hash-code for the given range. The hash-value will vary for every execution. Syntax: range1.hash() Parameters: The function accepts no parameter. Return Value: It returns a hash-code for the given range. Example 1: Ruby # Ruby program for hash() # me 1 min read Ruby | Range last() function The last() is an inbuilt method in Ruby returns an array of last X elements. If X is not mentioned, it returns the last element only. Syntax: range1.last(X) Parameters: The function accepts X which is the number of elements from the end. Return Value: It returns an array of last X elements. Example 1 min read Ruby | Set member?() function The member?() is an inbuilt method in Ruby returns true if the set contains the given object. It returns false if it does not contains the given object. Syntax: s1_name.member?(object) Parameters: The function accepts a mandatory parameter object whose presence is to be checked for. Return Value: It 1 min read Ruby | Range inspect() function The inspect() is an inbuilt method in Ruby returns the range object in a printable form Syntax: range1.inspect() Parameters: The function accepts no parameter Return Value: It returns the range object in a printable form Example 1: Ruby # Ruby program for inspect() # method in Range # Initialize ran 1 min read Ruby | Range include?() function The include?() is an inbuilt method in Ruby returns a boolean value true if the given object lies within the given range, else it returns false. Syntax: range1.include?(obj) Parameters: The function accepts an object which is to be checked for. Return Value: It returns a boolean value true if the gi 1 min read Like