C
C#5w ago
EggxFil

✅ just a quick question about if, else, else if

is there an order i must put it in? or like u can put if then else then else if?
11 Replies
Angius
Angius5w ago
There is an order, yes An if/else-if/else will execute top to bottom
EggxFil
EggxFil5w ago
alr thanks i assume if u do it any other way you will get an error right?
MODiX
MODiX5w ago
Angius
REPL Result: Failure
int a = 0;
else {
a = 100;
}
if (a == 50) {
a = 9;
}
else if (a == 9) {
a = 2;
}
int a = 0;
else {
a = 100;
}
if (a == 50) {
a = 9;
}
else if (a == 9) {
a = 2;
}
Exception: CompilationErrorException
- 'else' cannot start a statement.
- Syntax error, '(' expected
- Invalid expression term 'else'
- ) expected
- Invalid expression term 'else'
- ; expected
- 'else' cannot start a statement.
- Syntax error, '(' expected
- Invalid expression term 'else'
- ) expected
- Invalid expression term 'else'
- ; expected
Compile: 208.531ms | Execution: 0.000ms | React with ❌ to remove this embed.
Angius
Angius5w ago
Yes
EggxFil
EggxFil5w ago
ok thanks last question what is that bot?
Angius
Angius5w ago
It's MODiX, a bot that runs a lot of stuff on this server Including the $repl service
MODiX
MODiX5w ago
(Did you mean !eval?) MODiX REPL (server): https://github.com/discord-csharp/CSharpRepl Command line interface REPL: https://github.com/waf/CSharpRepl https://media.discordapp.net/attachments/569261465463160900/1151055959444160582/image.png 1: install the tool globally 2: Open WT settings + add the profile to the WT profile list 3: open the profile via drop down 4: it's an example of that profile open as a tab 5: learn to use C# in it
Angius
Angius5w ago
uh $eval
MODiX
MODiX5w ago
Compile C# code in #bot-spam, use !eval Example:
!eval for(int i = 0; i < 4; i++) Console.WriteLine(i);
!eval for(int i = 0; i < 4; i++) Console.WriteLine(i);
Angius
Angius5w ago
Yeah, this one
EggxFil
EggxFil5w ago
wow thats useful alr thank you i appreciate it