if statements without requiring else statements
Closed this issue · 1 comments
TimotejFasiang commented
Is your feature request related to a problem? Please describe.
Theoretically, if statements shouldn't need an else statement to follow them.
def main:
if 1 == 1:
return "true"
n = 1
# returns error: - expected: 'else'
Describe the solution you'd like
Remove requirement for else statement after an if statement.
Describe alternatives you've considered
Leaving it the way it is doesn't cause any issues, it just makes coding a tiny bit slower.
developedby commented
It is the way it is by design and we won't change it.
Yes, we could allow for not using else
in some situation like the one you said, but this obfuscates what the language is actually doing and will cause a lot of confusion and mistakes.
def main:
a = foo()
b = bar()
if equal(a, b):
a = 0
b = 1
return (a, b)
This for example will not have the expected effect.