Home / Questions / Can the curly brackets { } be used to enclose a single line of code?
Explanatory Question

Can the curly brackets { } be used to enclose a single line of code?

👁 3,884 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

While curly brackets are mainly used to group several lines of codes, it will still work without error if you used it for a single line. Some programmers prefer this method as a way of organizing codes to make it look clearer, especially in conditional statements.