Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

I used no curly brackets in my if else statement, and it is still correct

I didn't use curly brackets in my if else statement, and it is still correct .

Why is this?

Best Answers

  • edited October 2020 Accepted Answer

    If you keep your whole statement on one line you don't need the curly brackets .

  • Islu_TerrasIslu_Terras Member
    Accepted Answer

    I got confused by that too yesterday.

    What i found out is that it is fine to not use curly brackets if you only write one Line of code into your if statement.

    As soon as you want to use more Lines inside your if statement your Programm can fail.

    So i think its best to simply always use curly brackets.


    Greetings, Islu.

Answers

Sign In or Register to comment.