Undefined values: Difference between revisions
Content added Content deleted
No edit summary |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Remove nyi, speculative type smiley example) |
||
Line 898: | Line 898: | ||
multi sub foo(Int:D $i where * != 0){ (0..100).roll / $i } # we will never divide by 0 |
multi sub foo(Int:D $i where * != 0){ (0..100).roll / $i } # we will never divide by 0 |
||
multi sub foo(Int:U $i){ die 'WELP! $i is undefined' } # because undefinedness is deadly |
multi sub foo(Int:U $i){ die 'WELP! $i is undefined' } # because undefinedness is deadly |
||
multi sub foo(Int:_ where * == 0){ die q{I'm sorry, Dave, I'm afraid I can't do that.} } |
|||
with $i { say 'defined' } # as "if" is looking for Bool::True, "with" is looking for *.defined |
with $i { say 'defined' } # as "if" is looking for Bool::True, "with" is looking for *.defined |