09-10-2017, 08:26 PM
(This post was last modified: 09-10-2017, 08:29 PM by LiTTleDRAgo.)
Oh no, that's a misinterpretation...
&& = and
&& != then
&& is not a THEN, THEN is different syntax.
if a < b and a > 0
if a < b && a > 0
Those two are the same thing. So if you do this :
if a < b then a > 0
It will be wrong in all sense.
And so, about the logic from (array[2] > array[3]) && array.clear, I think I need rewording it for a bit.
What I used in there, is behavior of ruby (or perhaps all of programming language), not the logic "THEN".
When using && in a conditional, if the first sentence "(array[2] > array[3])" is wrong, the second sentence array.clear will not be executed.
That's why you can exploit it to replace "if" in some occasion.
Let's look at this example:
(0 + 1 == 1) && (1 + 1 == 2) && (2 + 2 == 4) && (4 + 4 == 5) && (5 + 5 == 10) && print "ALL CORRECT"
If looking at the sentences there, you can see that (4 + 4 == 5) is totally wrong, so if you dismantle it, it will look like this:
true && true && true && false && true && print "ALL CORRECT"
true and true and true and false and true and print "ALL CORRECT"
The process would stop at false and the program will not print "ALL CORRECT".
Or more correctly, the program will not read (5 + 5 == 10) and rest of the sentence at all.
Actually "or" / "||" also can be exploited into shortcut but I think I'll pass explaining it for now, maybe tomorrow.
&& = and
&& != then
&& is not a THEN, THEN is different syntax.
if a < b and a > 0
if a < b && a > 0
Those two are the same thing. So if you do this :
if a < b then a > 0
It will be wrong in all sense.
And so, about the logic from (array[2] > array[3]) && array.clear, I think I need rewording it for a bit.
What I used in there, is behavior of ruby (or perhaps all of programming language), not the logic "THEN".
When using && in a conditional, if the first sentence "(array[2] > array[3])" is wrong, the second sentence array.clear will not be executed.
That's why you can exploit it to replace "if" in some occasion.
Let's look at this example:
(0 + 1 == 1) && (1 + 1 == 2) && (2 + 2 == 4) && (4 + 4 == 5) && (5 + 5 == 10) && print "ALL CORRECT"
If looking at the sentences there, you can see that (4 + 4 == 5) is totally wrong, so if you dismantle it, it will look like this:
true && true && true && false && true && print "ALL CORRECT"
true and true and true and false and true and print "ALL CORRECT"
The process would stop at false and the program will not print "ALL CORRECT".
Or more correctly, the program will not read (5 + 5 == 10) and rest of the sentence at all.
Actually "or" / "||" also can be exploited into shortcut but I think I'll pass explaining it for now, maybe tomorrow.