string comparison

B

Boris Glawe

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top