Skip to main content
added 21 characters in body
Source Link
janos
  • 113.1k
  • 15
  • 154
  • 396

You can create a block without an if statement. For example, these are equivalent:

{
    // some code
}

if (true) {
    // some code
}

But it's not a good practice to create blocks like this. It's a code smell, suggesting to wrap // some code in a dedicated function instead.

Anytime you think some neat trick is "unconventional", it's most probably a bad practice. Don't do it, fix it.

You can create a block without an if statement. For example, these are equivalent:

{
    // some code
}

if (true) {
    // some code
}

But it's not a good practice to create blocks like this. It's a code smell, suggesting to wrap // some code in a dedicated function instead.

Anytime you think some neat trick is "unconventional", it's most probably a bad practice.

You can create a block without an if statement. For example, these are equivalent:

{
    // some code
}

if (true) {
    // some code
}

But it's not a good practice to create blocks like this. It's a code smell, suggesting to wrap // some code in a dedicated function instead.

Anytime you think some neat trick is "unconventional", it's most probably a bad practice. Don't do it, fix it.

Source Link
janos
  • 113.1k
  • 15
  • 154
  • 396

You can create a block without an if statement. For example, these are equivalent:

{
    // some code
}

if (true) {
    // some code
}

But it's not a good practice to create blocks like this. It's a code smell, suggesting to wrap // some code in a dedicated function instead.

Anytime you think some neat trick is "unconventional", it's most probably a bad practice.