Dios

 view release on metacpan or  search on metacpan

lib/Dios.pm  view on Meta::CPAN

constrainedness), sort them in order of declaration.

=item 3.

Call the first variant in the sorted list, or throw an exception if
the list is empty.

=back

Multifuncs and multimethods are a useful alternative to internal C<if>/C<elsif>
cascades. For example, instead of:

    func show (Num|Str|Array $x) {
        ref($x) eq 'ARRAY'     ?  '['.join(',', map {dump $_} @$a).']'
      : looks_like_number($x)  ?    $x
      :                           "'$x'"
    }

you could write:

    multi func show (Array $a) { '['.join(',', map {dump $_} @$a).']'}



( run in 0.522 second using v1.01-cache-2.11-cpan-49f99fa48dc )