Skip to content

Bug in match example #3 #4023

Closed
Closed
@bkp23

Description

@bkp23

From manual page: https://php.net/control-structures.match

EXAMPLE #3 reads:

$output = match (true) {
    $age < 2 => "Baby",
    $age < 13 => "Child",
    $age <= 19 => "Teenager",
    $age > 19 => "Young adult",
    $age >= 40 => "Old adult"
};

This will fail when $age is above 40 because it will still print "Young adult". It's impossible to get "Old adult" out of the example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions