4 ms·
Out of curiousity, which languages are you referring to? Assignment in if-statements is possible in C, C++, js, Go, and many other C-like languages. I think th
by leshow 7y ago
Out of curiousity, which languages are you referring to? Assignment in if-statements is possible in C, C++, js, Go, and many other C-like languages.
I think the only language I know of that disallows assignment in them is python, and it's not because assignment evaluates to something other than boolean, python is happen to evaluate the 'truthiness' of certain types. And funnily enough, they are going to add this back in to python 3 I believe, using a different operator.
- skohan 7y agoSwift, Kotlin, D, C# to name a few. Are you sure about Go? I just tried this in an online playground, and I get this error: syntax error: assignment x = 2 used as value