Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > string comparison

Reply
Thread Tools

string comparison

 
 
Boris Glawe
Guest
Posts: n/a
 
      12-14-2005
Hi,

I have a class containing a string as an instance variable and I have a local
variable containing a string.

I compare these two strings with '==' and with the .eql? method:

###################################

obj.text = "hello world"
localtext = "hello world"

if obj.text == localtext
then
# do something
end

###################################

The condition never became true in my program. Thus I added some debug output.
This is the the debugging code:

if not obj.text == localtext
then
print "\"#{obj.text}\" is not equal \"#{localtext}\"\n"
end

This is, what it gave me:

"hello world" is not equal "hello world"

It's not worth trying the example above, since it's not the actual code. The
actual code in my project is much more complex, that's why I used this example
to discribe my problem.

Fact is that when the string comparison does not succeed I get an output like

"hello world" is not equal "hello "world"

Now it's your turn... What could cause this behaviour?

thanks and greets

Boris


P.S. I have cancelled another message, which had a syntax error in my example
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparison of 2 files and generating the output based on comparison Deepu Perl Misc 1 02-07-2011 03:09 PM
False Positives From String Comparison using string.Equals() Smithers ASP .Net 12 07-07-2009 01:23 AM
Price Comparison Service. Best Deal. Special Coupon atBest-Price-Comparison.com rapee Digital Photography 0 03-14-2008 06:46 AM
Is there systematic performance comparison of std::string and c style string? yu_kuo@sina.com C++ 21 08-18-2007 04:32 PM
simple jsp string comparison Jason Java 2 09-20-2003 12:16 AM



Advertisments