On 07/03/2015 10:02 PM, yary wrote:
> On Fri, Jul 3, 2015 at 3:03 PM, Timo Paulssen <t...@wakelift.de> wrote:
>> but this does not
>>
>>> sub takes_int_array(Int @bar) { say @bar }
>>> takes_int_array([1, 2, 3])
>> because the type match is against the defined type. We do not
>> automatically infer that [1, 2, 3] could be a Positional[Int].
> How would one call "takes_int_array" with a literal [1,2,3]? Can we
> declare it to be a "Positional[Int]" or create an object of that type
> in-line?
>
> -y
You can Array[Int].new(1, 2, 3) and that will typematch against
Positional[Int].

A Positional[Int] by itself will not be of much use, as it doesn't
actually implement any kind of storage or constructor.

You can also write "takes_int_array(my Int @ = 1, 2, 3)".

Reply via email to