If Else and other statements
Closed this issue · 4 comments
mbartlett21 commented
Why does Oh Noes need a block statement after if, else, etc.
I find it a bit annoying because most of my if statements only have a single statement after them :(
Dalendrion commented
It's good practice to always have curly braces.
Say an inexperienced programmer wants to add a second line to that if
statement. The programmer might forget to add the curly braces, thus
introducing a bug.
As it happens, most KA users are indeed inexperienced.
…On Fri, Jul 20, 2018, 09:53 morganb21 ***@***.***> wrote:
Why does Oh Noes need a block statement after if, else, etc.
I find it a bit annoying because most of my if statements only have a
single statement after them :(
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#664>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJn3MTT61B8FWaDGbYO6do9XrtG6czp8ks5uIYyTgaJpZM4VXmy0>
.
pamelafox commented
Yes, as Dalendrion says, it helps new programmers to learn good habits and write less-error-prone code by forcing them to write their if blocks with curly statements. It's so often that I've seen a new programmer add an extra line to a single-line if, not realizing it's not actually inside the if.
I'm closing this issue, since it is working as intended.
mbartlett21 commented
Don't worry:
I found I could get around it in my code by using
//jshint curly:false
naclcaleb commented
This is still open, but could be closed...