styleguides
styleguides copied to clipboard
Wrong example for "Don't chain assignments"?
Chapter "Don't chain assignments" currently has the following two code snippets:
var2 = var3.
var1 = var3.
var1 = xsdbool( var2 = var3 ).
Can someone please explain to me what the xsdbool
code snippet has to do with the topic? It doesn't make any sense to me to assign the boolean abap_true
to var1
. It has the value of var2
and var3
, but not necessarily a boolean and it is not necessarily true.
It's about ABAP lacking the syntax distinction between assignment (=
) and comparison (=
).
JavaScript assigns with =
and compares with ==
or ===
.
The ABAP statement a = b = c.
thus looks ambiguous, and if we intend a = ( b == c )
then we should use xsdbool
.
OK, thanks for the explanation. I believe this information could be better conveyed in the guideline. I have proposed a change to this section.