On 2020-01-09 06:56, ToddAndMargo via perl6-users wrote:
    <perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote:

        Hi All,

        In a sub declaration, is there a way to constrain
        a variable to only an "int32" or a "Str" (I want both)?
        Or do I have to put up with the other types of "Any"?

        Many thanks,
        -T


On Thu, 9 Jan 2020 at 08:13, WFB <wolfgang.banas...@gmail.com <mailto:wolfgang.banas...@gmail.com>> wrote:

    Hi, Todd,

    If I understand your question right, then you mean something like that:

    sub do-soemthing($value where { .WHAT ~~ Str || .WHAT ~~ Int }) {}

    https://docs.raku.org/type/Signature#index-entry-where_clause

    Regards

    On Thu, 9 Jan 2020 at 03:58, ToddAndMargo via perl6-users


On 2020-01-08 23:14, WFB wrote:
For the sake of readability you might want use a subset:
https://docs.raku.org/language/typesystem#subset


Hi W,

Subset does no seems to be what I am after, but "where"
does.   Thank you!

-T

Hi W,

I might be changing my mind.  It would not be the
first time you have done that to me.

:-)

-T

Reply via email to