rfc:switch-expression-and-statement-improvement

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
rfc:switch-expression-and-statement-improvement [2019/09/26 14:06] – fixed missing parens brzuchalrfc:switch-expression-and-statement-improvement [2019/09/26 14:17] brzuchal
Line 25: Line 25:
   case 0:   case 0:
     $say = "weekend!";     $say = "weekend!";
 +    break;
   case 1:   case 1:
   case 2:   case 2:
Line 50: Line 51:
   case 0:   case 0:
     $say = "weekend!";     $say = "weekend!";
 +    break;
   case 1, 2, 3, 4, 5:   case 1, 2, 3, 4, 5:
     $say = "weekday :(";     $say = "weekday :(";
Line 82: Line 84:
 ==== Return type ==== ==== Return type ====
  
-The nature of switch expression which returns matched expression block allows specifying an optional return  +The switch expression errors with ''RuntimeException'' if return type given and there is a type mismatch.
-type-hint to enforce result type restriction.+
  
 <code php> <code php>
Line 98: Line 99:
 ==== Non-completeness ==== ==== Non-completeness ====
  
-The nature of switch statement returning always a value which must match optional type-hint if given +The witch statement returning errors with ''RuntimeException'' if none of the labels evaluated on a match.
-results in RuntimeException if none of the labels evaluated on a match.+
  
 <code php> <code php>
rfc/switch-expression-and-statement-improvement.txt · Last modified: 2020/07/22 08:39 by brzuchal