Here is a sample program to compare two strings in Ruby if the two string is identical or not to one another.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.
My personal website is http://www.jakerpomperada.com
Sample Program Output
Program Listing
compare.rb
# compare.rb
# Author : Jake Rodriguez Pomperada,BSCS,MAED-IT
# Date : July 10, 2019 Wednesday 10:00 AM
# Address : Bacolod City, Negros Occidental
# Tools : Eclipse IDE and Ruby Version 2.6.3
# Location : Bacolod City, Negros Occidental
# Website : http://www.jakerpomperada.com
# Emails : jakerpomperada@gmail.com and jakerpomperada@yahoo.com
print "\n\n"
print "\t===== Comparing Two Strings ====="
print "\n\n"
s1 = "Jacob"
s2 = "Jacob"
s3 = s1
print "\tThe given string value no. 1 : #{s1}\n"
print "\n"
print "\tThe given string value no. 2 : #{s2}\n"
print "\n"
if s1 == s2
print "\tBoth Strings have identical content\n"
else
print "\tBoth Strings do not have identical content\n"
end
if s1.eql?(s2)
print "\tBoth Strings have identical content\n"
else
print "\tBoth Strings do not have identical content\n"
end
if s1.equal?(s2)
print "\tTwo Strings are identical objects\n"
else
print "\tTwo Strings are not identical objects\n"
end
if s1.equal?(s3)
print "\tTwo Strings are identical objects\n"
else
print "\tTwo Strings are not identical objects\n"
end
print "\n\n";
print "\tEnd of Program"