Generic array field syntax?

About Monkey 2 Forums Monkey 2 Programming Help Generic array field syntax?

This topic contains 4 replies, has 3 voices, and was last updated by  abakobo 3 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #15973

    jondecker76
    Participant

    I’ve been trying to figure this out for a bit now.  I would like to have a generic array as a field in a class method, but I just can’t seem to get the syntax right.  Ive tried..

    and various other attempts, but just can’t seem to get it to work.  I would like the “arr” field to be an array of whichever object I want to set it as.  Is this possible?

     

    Thanks

    #15974

    Danilo
    Participant

    You can use the type Variant to set it to whichever object you want.

    #15975

    Danilo
    Participant

    A generic class with an array would look like this:

    #15976

    jondecker76
    Participant

    Thanks!  Quite helpful!

    #15979

    abakobo
    Participant

    Generics are always associated with a function, class or struct. Generic interfaces were not available, I think it’s not available yet.

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

You must be logged in to reply to this topic.