Re: Hash Constraints w/in subset's

2020-02-01 Thread Paul Procacci
Thanks for all the answers. This will get me going. I was unaware of the ' Hash[Int, Str]' type of declarative syntax. I knew Hash[Str] was a thing but was unaware of the '[Int,Str]' type of syntax. Thanks for the insight! On Sat, Feb 1, 2020 at 11:16 AM Elizabeth Mattijsen wrote: >

Re: Hash Constraints w/in subset's

2020-02-01 Thread Elizabeth Mattijsen
subset PhoneNumber of Int where *.chars == 9; # or any other constraint constant PhoneBook = Hash[PhoneNumber, Str]; # no need to make a class, a type suffices my %pb is PhoneBook = foo => 123456789; dd %pb; # (my PhoneNumber %{Str} = :foo(123456789))

Re: Hash Constraints w/in subset's

2020-02-01 Thread Brad Gilbert
I wouldn't use a subset like this: subset PhoneBook of Hash[Int, Str]; I would instead use a constant: constant PhoneBook = Hash[Int, Str]; Then you can use that for creating new instances. PhoneBook.new(); # Hash[Int, Str].new() # or my %pb is PhoneBook; # my Int

Re: Hash Constraints w/in subset's

2020-02-01 Thread Tobias Boege
On Sat, 01 Feb 2020, Paul Procacci wrote: > Hey ladies/gents, > > How would one go about defining a subset of a Hash who's key's and values > are both constrained by something > > I've read https://docs.perl6.org/type/Hash and it does make mention of > constraining keys and values, but not

Hash Constraints w/in subset's

2020-02-01 Thread Paul Procacci
Hey ladies/gents, How would one go about defining a subset of a Hash who's key's and values are both constrained by something I've read https://docs.perl6.org/type/Hash and it does make mention of constraining keys and values, but not within the context of a subset. Before I go ripping my