Generic function types?

About Monkey 2 Forums Monkey 2 Development Generic function types?

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

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

    Arjailer
    Participant

    Is it possible to have generic function types? For example I’d like to do this:

    So that I don’t have to repeat as much boilerplate code for each test I write. This is something I do all the time in my C# day job and it’d be great to be able to use the same patterns  🙂

    It doesn’t seem to be possible, but I might just be getting the syntax wrong.

    #2886

    Mark Sibly
    Keymaster

    Not sure what you’re trying to do there – why is TestGenericClass a method? etc…

    Generic methods/functions are supported though, eg:

    You need the ‘<T>’ after the ‘Min’ so the compiler knows that ‘x:T’ and ‘y:T’ refer to generic types, not just a type ‘T’ that might be declared elsewhere.

    #2889

    Arjailer
    Participant

    Hmmm … I’m getting myself confused …

    I was writing tests for a generic class and wanted to test it with various types. To do this I was having to write two methods for each test, sort of like:

    This was getting a bit tedious, so I was looking for a way to cut this down a bit.

    But thinking about it again there’s two obvious problems with that:

    • What I was trying to do was nonsense (I somehow convinced myself that what I was trying to do was possible in C#, but it’s not – total brain-fart)
    • I don’t need to test it with different types – one is enough (another brain-fart)

    So, sorry to waste your time  🙂

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

You must be logged in to reply to this topic.