DEV Community

loading...

Discussion on: Know more about if(x=y)

Collapse
nazanin_ashrafi profile image
Nazanin Ashrafi

Awesome article and very simple explanation 🙌🙌😍

Quick question tho :D
When should we use if(x=y) ?

Collapse
hardikchopra242 profile image
Hardik Chopra

I think in the condition box, we should always use == and never use = intentionally.

Collapse
ritvikdubey27 profile image
Ritvik Dubey Author

Yeah he is right we should not use = intentionally. This article was just for information.

Collapse
pgradot profile image
Pierre Gradot

Never.

With g++, you get a warning with -Wall. See online.

warning: suggest parentheses around assignment used as truth value [-Wparentheses]