Typed Pairs

2019-09-05 Thread Mikkel
Hello I am wondering whether it is possible to define a Pair with a key and a value of a specific class. Suppose I want an Array of Pairs with keys as Str and values as Array of Str called "properties". And define it as a instance variable.Something of the likes: has Pair[Str, Array[Str]] @!prop

Re: Variable character class

2019-09-05 Thread Gianni Ceccarelli
On Wed, 4 Sep 2019 21:44:29 -0700 William Michels via perl6-users wrote: > Hi Gianni, I'm not sure of the Perl5 case, but what you're saying is, > if your target string is backslashed, be sure to "quote-interpolate > it" in Perl6? (see below): Re-reading what I wrote, I realise it was really not

Re: Typed Pairs

2019-09-05 Thread yary
this looks like two questions- typing Array contents - see Typing Syntax is "my @bucket of TypedThings;" typing a Pair > my Pair[Str, Array[Str]] $x; ===SORRY!=== Error while compiling: An exception occurred while parameterizing Pair at :1 Exception

Re: Typed Pairs

2019-09-05 Thread Timo Paulssen
You can try defining a subset type a bit like this: subset StrArrStrsPair of Pair where .key ~~ Str && .value ~~ Positional[Str]; Please be aware that the arrays have to be explicitly created with the type constant of Str for this to work. On 5 September 2019 14:34:05 CEST, Mikkel wrote: >Hell

Re: Variable character class

2019-09-05 Thread William Michels via perl6-users
Hi Gianni, I think we're looking at two different aspects of the same problem. I'm just concerned with learning Perl6 regexes. Presumably many people will continue to use Perl5 regexes for a long time to come (for reasons of familiarity, and/or speed). Regarding Perl6 regexes, your last two P6 ex