0
Look this sample Php code, what it is the output? It's allowed? I try to do the same in Java. It's too strict. Who is right?
https://code.sololearn.com/wA9b4YU0MOI4/?ref=app https://code.sololearn.com/cxxz7Hw2QdJ4/?ref=app
4 Respuestas
+ 1
You have to put == for comparison instead of =, if you want to actually compare.
if($a = $x) {
\\ This is executed whenever the assignation is valid.
}
0
I prefer the Php approach. It evaluated all arguments and pass the result to if... Java expect a boolean expression/values, so don't allow you to make assignment in if. More formal, but LESS expressive and so long to write some rows of code!
0
obviously in java I can't do the same..
0
yes bebida, this is the purpouse of the code, and it works also if it's conceptually wrong!