Cant overload Get in StringMap

About Monkey 2 Forums Monkey 2 Development Cant overload Get in StringMap

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1057

    therevills
    Participant

    Example:

    Error : Method ‘Get:Screen(string)’ overrides a non-virtual superclass method

    #1060

    Mark Sibly
    Keymaster

    Map.Get is final and cannot be overriden.

    IMO, best approach is for ScreenBank to have an internal _map field and present it’s own interface, but you could also add a GetScreen method if you really want to extend Map.

    #1065

    therevills
    Participant

    Thanks for the reply Mark, I had already implemented the GetScreen method before I posted. In MX1 we could override Map.Get, any reason why you have decided to make it final in MX2?

    #1067

    Mark Sibly
    Keymaster

    > In MX1 we could override Map.Get, any reason why you have decided to make it final in MX2?

    Basically because I think it’s a better design. You can read some of the arguments for and against virtual methods vs final methods and why I prefer final unless there’s a good reason to make some virtual here:

    http://www.monkey-x.com/Community/posts.php?topic=10392&page=1

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

You must be logged in to reply to this topic.