In this shot, we will check if two strings are equal with the
eql?() method. Two strings are equal if they both have the same length and content with the same case.
other_str: The string we compare with the string instance.
The value returned is a Boolean. It returns the
true if the strings are equal. Otherwise,
false is returned.
# compare strings puts "one".eql?("one"); # true puts "two".eql?("two"); # true puts "three".eql?("three"); # true puts "FIVE".eql?("five"); # false puts "six".eql?("Six"); # false
All the first three string comparisons return
true because they are equal. The rest are not equal because they are not of the same case. That is why they will return
View all Courses