Forum: Ruby is there "equalsIgnoreCase" in ruby?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
viswesh (Guest)
on 2006-05-17 19:40
Hi

Please let me know whether any method similar to ("equalsIgnoreCase" in
java)
exists in ruby as well...

thanx
Austin Z. (Guest)
on 2006-05-17 19:56
(Received via mailing list)
On 5/17/06, viswesh <removed_email_address@domain.invalid> wrote:
> Please let me know whether any method similar to ("equalsIgnoreCase" in
> java)
> exists in ruby as well...

What does equalsIgnoreCase do, and could you not have spent five
minutes to Google?

-austin
Lyle J. (Guest)
on 2006-05-17 19:57
(Received via mailing list)
On 5/17/06, viswesh <removed_email_address@domain.invalid> wrote:

> Please let me know whether any method similar to ("equalsIgnoreCase" in
> java)
> exists in ruby as well...

Yes, it's called String#casecmp().
viswesh (Guest)
on 2006-05-17 20:46
Hi Johnson,

can u please correct the code...

puts " what is your name"
name = gets.chomp

puts " hello "+ name+" how are you"
fine = gets.chomp

if 	fine == "good".casecmp("goo")
	#fine == "fine" or
	#fine == "ok" or
	#fine == "wonderfull"
puts " great"
else
  puts "oh iam sorry"
end


thanx


Lyle J. wrote:
> On 5/17/06, viswesh <removed_email_address@domain.invalid> wrote:
>
>> Please let me know whether any method similar to ("equalsIgnoreCase" in
>> java)
>> exists in ruby as well...
>
> Yes, it's called String#casecmp().
Lyle J. (Guest)
on 2006-05-17 20:59
(Received via mailing list)
On 5/17/06, viswesh <removed_email_address@domain.invalid> wrote:

> if      fine == "good".casecmp("goo")
>         #fine == "fine" or
>         #fine == "ok" or
>         #fine == "wonderfull"

I think that maybe you mean to write:

    if fine.casecmp("good")
      puts "Great!"
    else
      puts "Oh, I'm sorry."
    end

Hope this helps,

Lyle
Tim B. (Guest)
on 2006-05-17 21:03
(Received via mailing list)
> can u please correct the code...

you forgot to tell us what you want the program  to do, what it's
doing instead, the things you've already tried to remedy the problem
and what you think might be the problem.
  -tim
John G. (Guest)
on 2006-05-17 21:03
(Received via mailing list)
On 5/17/06, viswesh <removed_email_address@domain.invalid> wrote:
> if      fine == "good".casecmp("goo")
>
>


See "ri String#casecmp".
This topic is locked and can not be replied to.