RUBY Programming, For Beginners, Quick Start Guide. by Ray Yao

RUBY Programming, For Beginners, Quick Start Guide. by Ray Yao

Author:Ray Yao [Yao, Ray]
Language: eng
Format: azw3
Publisher: Step by Step Tutorial eBook & Book
Published: 2020-08-06T00:00:00+00:00


Comparing String

The string can be compared by using following three operators.

==

eql?

casecmp

== operator: returns true or false.

eql? operator: returns true or false.

casecmp method: if match, it returns 0. if not match, it returns 1.

Example 5.7

puts "ABCD" == "AB CD"

puts "Good" == "Good"

puts "OK" .eql? "KO"

puts "100" .eql? "100"

puts "PHP" .casecmp "PHP"

puts "MySQL" .casecmp "HTML"

Output:

false

true

False

true

0

1

Explanation:

== operator: returns true or false.

eql? operator: returns true or false.

casecmp method: if match, it returns 0. if not match, it returns 1.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.