Horje
Ruby | Set <= method

The <= is an inbuilt method in Ruby returns true if the set is a subset of the given set.

Syntax: s1_name <= s2_name

Parameters: The function takes a mandatory parameter with which it is checked for subset.

Return Value: It returns self.

Example 1:




# Ruby program to illustrate 
# the <= method 
   
# requires the set 
require "set"
   
s1 = Set[2, 12, 78, 10, 87, 98
s2 = Set[2, 10, 87]
   
# reset method used 
puts s2 <= s1

Output:

true

Example 2:




# Ruby program to illustrate 
# the <= method 
   
# requires the set 
require "set"
   
s1 = Set[2, 12, 78, 10, 87, 98
s2 = Set[1, 2, 3]
   
# reset method used 
puts s2 <= s1

Output:

false



Reffered: https://www.geeksforgeeks.org


Ruby

Related
Ruby | Set subset? function Ruby | Set subset? function
Ruby | Hash store() method Ruby | Hash store() method
Ruby | Hash size() method Ruby | Hash size() method
Ruby | Time gmt? function Ruby | Time gmt? function
Ruby | Hash shift() method Ruby | Hash shift() method

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
9