In code, why wouldn't this work?
开发者_开发百科intMax = intTopValue = 20
This is interpreted as intMax = (intTopValue = 20)
.
intTopValue = 20
will check whether intTopValue
is equal to 20
and return true or false.
This boolean will then be assigned to intMax
.
Most languages don't have this issue, since they use separate operators for assignment (=
or :=
) and equality (==
or =
).
By contrast, VB shares =
for both operations. Therefore, when a = b
is written as an expression, it always means equality.
精彩评论