Skip to content
Related Articles

Related Articles

Ruby | String eql? Method
  • Last Updated : 12 Dec, 2019

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:



filter_none

edit
close

play_arrow

link
brightness_4
code

# 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


Output:

true
false

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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


Output:

false
true
My Personal Notes arrow_drop_up
Recommended Articles
Page :