Ruby | String eql? Method
eql? is a String class method in Ruby which is used to check whether the strings are equal or not if they have the same length and content.
Syntax: str.eql?(Other_str)
Parameters: Here, str and other_str are the strings.
Returns: True or false basis on the equality.
Example 1:
# Ruby program to demonstrate # the eql? method # Taking a string and # using the methodputs "Sample".eql?("Sample") # case sensitiveputs "Program".eql?("program") |
Output:
true false
Example 2:
# Ruby program to demonstrate # the eql? method # Taking a string and # using the methodputs "Ruby".eql?("ruby") # case sensitiveputs "String".eql?("String") |
Output:
false true



