+ 1
Why is it not working?
var distance=4 if distance==0{ print("not a valid distance") } else if distance==1 || distance==2 || distance==3 || distance==4 || distance ==5{ print("near")} else{ print("too far")}
4 Respuestas
+ 5
EDIT: I wasn't aware that space matters in swift, their should be space around the operators
like in your if case
if distance==0 is considered wrong
it should be distance == 0, (have space around the operators
https://code.sololearn.com/cq8GKB2dN2j6/?ref=app
+ 7
Give some spaces between == equality operator after distance and before right value it will work without any errors
+ 1
Мг. Кнап🌠
No i didn't copy it.
I tried to write
the switch ,case and default
with boolean and if statements.
+ 1
Baratov Hojiakbar i take my words back, see the edited response, hope it answers your question