It looks like you're new here. If you want to get involved, click one of these buttons!
{(set: $target="12") (set: $current="$num1"+"$num2") (set: $num1 = "1") (set: $num2 = "2") (set: $test = "12") $target = $current? (if: $target is $current)[ YES] (else:)[NO] <br> $target = $test? (if: $target is $test)[ YES] (else:)[NO] }
Comments
Regardless, your primary issue is with your assignment to $current. You're assigning it the value of the expression "$num1"+"$num2", which becomes the string "$num1$num2"—using Test mode should show this. That's why it doesn't equal $target when you compare them—i.e. "12" does not equal "$num1$num2", even though they print out similarly. Basically, you assigned it the names of the variables, $num1 and $num2, rather than their values. Whether your intention was to use numbers or numeric strings, the assignment should have been something like:
Also, if your intention was to assign $current the values of $num1 and $num2, rather than their names, then you cannot use them in an expression before you've actually done their assignment first—i.e. you have them out of order.
Your assignments should look something like the following if you wanted numeric strings:
Or the following if you wanted actual numbers:
The comparisons don't need to change either way.
Yes, without quotes in $current it works perfectly!
Thanks a lot!
if you try to use quotes instead of String() - the variable will get the value "(random: 0, 9)" instead of the random function's result. So it will not be able to compare too.
(which is a big surprise for me cause I thought that String() and quotes are the same thing)
I hope it will be useful.