String Comparison


#1

Hi Everyone ! Below is a little snippet.

There is a difference in both the string. But the true condition is executed and I get the result as "its equal or true". But the expected output is the other one in 'else'. Please help.

var_1="Dinesh"

var_2="Dnesh"

if var_1=var_2
print "its equal or true "
else
print "no am not :wink: "
end


#2

Hello :slight_smile:

To check if two variables have the same value you have to use a equality check operator (==).

var_1="Dinesh"

var_2="Dnesh"

if var_1==var_2
    print "its equal or true "
else
    print "no am not ;) "
end

#3

Thanks for the help. '==' works !!
Yes, the missing "i" was intentional to get the code to 'else'.


#4

Yeah, I edited my post just a second ago. I should read more carefully :slight_smile:

You're very welcome.