The == is an inbuilt method in Ruby returns true if other has the same struct subclass and has equal member values.
Syntax: struct1 == struct2
Parameters: The function accepts no parameter.
Return Value: It returns boolean value true if both the given ranges are equal, else it returns false.
Example 1:
# Ruby program for == method in struct # Include struct Employee = Struct.new(:company_name, :position, :zip) #initialise struct struct1 = Employee.new("GEEK", "INTERN", 12345) struct2 = Employee.new("GEEK", "INTERN", 12345) # Prints the value of struct1==struct2 puts struct1 == struct2 |
chevron_right
filter_none
Output:
true
Example 2:
# Ruby program for == method in struct # Include struct Employee = Struct.new(:company_name, :position, :zip) #initialise struct struct1 = Employee.new("GEEK", "INTERN", 12345) struct2 = Employee.new("geeksforgeeks", "INTERN", 12345) # Prints the value of struct1==struct2 puts struct1 == struct2 |
chevron_right
filter_none
Output:
false
Recommended Posts:
- Ruby | Struct to_s() function
- Ruby | Struct eql?() function
- Ruby | Struct values() function
- Ruby | Struct length() function
- Ruby | Struct members() function
- Ruby | Struct size() function
- Ruby | Struct to_a() function
- Ruby | Struct values_at() function
- Ruby | Struct filter() function
- Ruby | Struct each() function
- Ruby | Struct inspect() function
- Ruby | Struct Class
- Ruby | Matrix cofactor() function
- Ruby Integer odd? function with example
- Ruby Integer div() function with example
- Ruby | Symbol to_s function
- Ruby | Set replace() function
- Ruby | Set reset() function
- Ruby | Array Concatenation using (+) function
- Ruby | at() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

