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:
puts "Sample" .eql?( "Sample" )
puts "Program" .eql?( "program" )
|
Output:
true
false
Example 2:
puts "Ruby" .eql?( "ruby" )
puts "String" .eql?( "String" )
|
Output:
false
true
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!