+ 1

Is it possible to leave out curly braces in the else statement as well if only one line of code is supposed to be executed?

26th Apr 2016, 7:37 PM
Th3Muff1n
Th3Muff1n - avatar
9 Respuestas
+ 6
Yes.. By default the scope of if and else is line next to it so for a single line execution you can leave out the curly braces.
13th Jun 2016, 8:09 AM
Shikhar Seth
Shikhar Seth - avatar
+ 1
Yup
20th May 2016, 9:17 AM
James Flanders
+ 1
you can...but don't leave the curly braces,just always makes the habit of putting curly braces in these types of statement. it won't alter your program👍
11th Jul 2016, 5:47 PM
osahil singh
osahil singh - avatar
+ 1
yes
15th Jul 2016, 6:41 AM
Mohit Kulkarni
Mohit Kulkarni - avatar
0
yes
11th Jun 2016, 12:01 PM
SHAHZAIB MEHFOOZ
SHAHZAIB MEHFOOZ - avatar
0
That's right.
13th Jun 2016, 3:40 AM
Pedro
Pedro - avatar
0
yes
13th Jun 2016, 9:03 AM
Iman Ali
Iman Ali - avatar
0
Yup! But if your sharing the program, curly braces are usually easier to read. :)
15th Aug 2016, 2:50 PM
Taj K.
0
that right way
3rd Sep 2016, 7:21 PM
Ashish kumar
Ashish kumar - avatar