match has a default case too. Also, you can comma-separate multiple values:
match
$fontWeight = match ($weight) { 100, 200 => "Super Thin", 300 => "Thin", 400, 500 => "Normal", 600, 700, 800 => "Bold", 900 => "Heavy", default => "Not valid" };
Edited the example in the article accordingly.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
match
has a default case too. Also, you can comma-separate multiple values:Edited the example in the article accordingly.