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 method puts "Sample".eql?("Sample") # case sensitive puts "Program".eql?("program") |
chevron_right
filter_none
Output:
true false
Example 2:
# Ruby program to demonstrate # the eql? method # Taking a string and # using the method puts "Ruby".eql?("ruby") # case sensitive puts "String".eql?("String") |
chevron_right
filter_none
Output:
false true
Recommended Posts:
- Ruby | String hex Method
- Ruby | String === Method
- Ruby | String << Method
- Ruby | String =~ Method
- Ruby | String chr Method
- Ruby | String * Method
- Ruby | String <=> Method
- Ruby | String == method
- Ruby | String + Method
- Ruby | String each_codepoint Method
- Ruby | String delete() Method
- Ruby | String crypt Method
- Ruby| String Clear Method
- Ruby | String codepoints Method
- Ruby | String count() Method
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.



