notes on virtual

About Monkey 2 Forums Monkey 2 Development notes on virtual

This topic contains 0 replies, has 1 voice, and was last updated by  codifies 2 years, 3 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #6329

    codifies
    Participant

    for some reason I missed seeing virtual…!

    Lets looks at some code…

    [/crayon]

    some output

    [/crayon]

    first off notice that import without it the code will still compile but reflection doesn’t work as expected – anyhow this isn’t needed I just happened to add the virtual test code to a code scrap that was floating about…

    Commonly you’d have a method that is entirely abstract, this is entirely without code, but sometimes it can be useful to have some default code that can be optionally used…

    Virtual allows this but it is actually more flexible than in some languages, from the D class amethod you can see that using Super I’m calling the original code – not only is that optional, but unlike some other languages Super doesn’t have to be the very first thing you do.

    I hope this little scrap allows someone struggling a little extra clue…

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.