develooper Front page | perl.perl6.users | Postings from September 2017

Hash and subs question

Thread Next
From:
ToddAndMargo
Date:
September 29, 2017 03:53
Subject:
Hash and subs question
Message ID:
4abe928f-139b-e780-98f8-ceb6fef8ce30@zoho.com
Hi All,

Looking at this test I threw together;

$ perl6 -e 'sub SayHash(%H) {say %H}; my %x = [aaa => "x", b=>"y", 
c=>"z"];SayHash(%x);'

{aaa => x, b => y, c => z}

I see that SayHash(%H) will take any hash I send it.

Is there a way to make the compiler pissed if a sub does not see
the specific keys int he hash it wants?  Or do I need to use loop
with ":exists" and test each key?

Many thanks,
-T

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About