Ruby | Struct == function Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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 # 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 Output: true Example 2: Ruby # 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 Output: false Comment More infoAdvertise with us Next Article Ruby | Struct to_s() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Struct-class Similar Reads Ruby | Struct eql?() function The eql?() is an inbuilt method in Ruby returns true if other has the same struct subclass and has equal member values. Syntax: struct1.eql?(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. 1 min read Ruby | Struct eql?() function The eql?() is an inbuilt method in Ruby returns true if other has the same struct subclass and has equal member values. Syntax: struct1.eql?(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. 1 min read Ruby | Struct to_s() function The to_s() is an inbuilt method in Ruby that returns a string with the value of the particular struct. Syntax: struct_name.to_s() Parameters: The function does not accepts any parameter. Return Value: It returns the value of struct. Example 1: Ruby # Ruby program for to_s method in struct # Include 1 min read Ruby | Struct to_s() function The to_s() is an inbuilt method in Ruby that returns a string with the value of the particular struct. Syntax: struct_name.to_s() Parameters: The function does not accepts any parameter. Return Value: It returns the value of struct. Example 1: Ruby # Ruby program for to_s method in struct # Include 1 min read Ruby | Struct each() function The each() is an inbuilt method in Ruby returns every value of the struct in the existing order. In case no block is passed, it returns an enumerator. Syntax: struct_name.each{|x| block } Parameters: The function accepts a single parameter block which is the way it is iterated. Return Value: It retu 1 min read Ruby | Struct each() function The each() is an inbuilt method in Ruby returns every value of the struct in the existing order. In case no block is passed, it returns an enumerator. Syntax: struct_name.each{|x| block } Parameters: The function accepts a single parameter block which is the way it is iterated. Return Value: It retu 1 min read Like