Type Juggler · Level 6 of 7

Stop catching

A function with an int parameter, called with 5 and with "5", in a file with strict_types on.

<?phpdeclare(strict_types=1);function twice(int $n): int {    return $n * 2;}echo twice(5) . PHP_EOL;try {    echo twice("5") . PHP_EOL;} catch (TypeError $e) {    echo 'TypeError' . PHP_EOL;}

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…