V
V
vadimm0s2019-08-08 17:53:28
Programming
vadimm0s, 2019-08-08 17:53:28

Why are back-to-front comparisons used, such as false == obj.prop.subProp?

I often meet, especially in all kinds of checks, in third-party code constructions like
false == obj.prop.subProp
or
1 == arr[8]
, etc.
It seems that the order "what" == "with what" or "variable" == "constant" is perceived as normal. Why
are "back to front" comparisons sometimes used, such as false == obj.prop.subProp?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Developer, 2019-08-08
@vadimm0s

It's called Yoda-style.
true/false is not accidentally assigned to a variable by mistake.
On the left, this value will be in the condition if, at the compilation stage, you will receive an error.

V
Vadim Shatalov, 2019-08-08
@netpastor

It doesn't really matter, young Padawan
But someone writes like this - he is already close to the dark side of the force

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question