✅ Else condition refusing to work- looks correct.
first one is what i'm trying to solve, second one is what the error shows, and the third is something else that looks the same but still doesn't work.



18 Replies
The
;
at the end of your if
statement shouldn't be therealso

(The compiler's even highlighted it with a yellow squiggle for you)
ah gonna get rid of that
What's happening is that an
if
statement needs to be followed by a block of code. If you put a ;
after the if
statement then that "block of code" is empty (it's everything up to the ;
), which means that the stuff following the if
statement isn't actually part of the if
canton7
REPL Result: Success
Console Output
Compile: 395.230ms | Execution: 35.396ms | React with ❌ to remove this embed.
That's the same as:
canton7
REPL Result: Success
Console Output
Compile: 383.948ms | Execution: 22.672ms | React with ❌ to remove this embed.
So what you wrote is equivalent to:
See how that
else
is out on its own without a corresponding if
? That's what the compiler's complaining aboutgonna try this
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Then you have beginners being very frustrated by NRT warnings 😛
Especially as
Console.ReadLine
returns a nullable stringwhoops- forgot to reply
this worcked!
worcked
Glad to hear!
$close
If you have no further questions, please use /close to mark the forum thread as answered
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
If someone's just getting started with a "Guess the number" game, IMO it's far too early to be introducing NRTs
TeBeCo
but at the same time driving them to insanity
Quoted by
<@689473681302224947> from #Else condition refusing to work- looks correct. (click here)
React with ❌ to remove this embed.