Help for this page

Select Code to Download


  1. or download this
    given($data) {
        when (1) { say 'one' ; };   ## no "break" needed
        when (2) { say 'two' ; };
        default  { say 'something else';  };
    }
    
  2. or download this
    # this code does not work !
    # it will say "something else"
    ...
        when (2) { say 'one or two' ; };
        default  { say 'something else';  };
    }
    
  3. or download this
    # this works, is shorter and easier to read
    given($data) {
        when ([ 1, 2]) { say 'one or two' ;  };
        default  { say 'something else';  };
    }