Page 1 of 1

[HD-OCP17/21-Fundamentals Pg 0, Sec. 12.3.3 - which-switch-syntax-to-use-old-or-new]

Posted: Mon Nov 25, 2024 5:34 pm
by joaoclopes
Hello!

Regarding the new syntax and old syntax of switch statement is quoted
You can do all the things with either of the syntaxes.
You can't do the fall through behavior in the new syntax for example.

Thanks!
João

Re: [HD-OCP17/21-Fundamentals Pg 0, Sec. 12.3.3 - which-switch-syntax-to-use-old-or-new]

Posted: Tue Nov 26, 2024 8:01 am
by admin
Actually the note is about implementing business logic using either of the syntaxes. It is like saying you can do everything using statement with a while statement that you can with a for statement. Of course, the code will be slightly different with both.

The point is about not mixing both the syntaxes in the same code base as they may cause confusion.

Re: [HD-OCP17/21-Fundamentals Pg 0, Sec. 12.3.3 - which-switch-syntax-to-use-old-or-new]

Posted: Tue Nov 26, 2024 7:01 pm
by joaoclopes
Thanks for the explanation!