Method/operator-level generics

About Monkey 2 Forums Monkey 2 Development Method/operator-level generics

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  Samah 2 years, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1134

    Samah
    Participant

    I want to be able to do something like this:

    [/crayon]

    But I get:

    Error : Can't find overload for '[](...)' with argument types (string)

    Is there a way I can do this?

    #1136

    Mark Sibly
    Keymaster

    Generic types are only infered from parameters. If a type can’t be infered from parameters, you need to explicitly specify it, which isn’t supported for operators so you’d need to use something like…

    …instead.

    #1139

    Samah
    Participant

    That’s a pity, some other languages can infer from the return type. 🙁
    I guess a “Get” method will have to be good enough.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.