Just discovered this new ‘feature’ in the Monkey2 language!
Of course it’s not really new (just re-read the Mark’s post on September 5th, 2016… ehm! – I really missed this!)
But it is very .., HANDY!
Imagine this: you have a Class already defined. Without change the main class (or create a new one using Class MyClass Extend Class) you could use this magic keyword
Class Image Extension Function LoadMasked:Image( imagePath:String,maskPath:String,textureFlags:TextureFlags=TextureFlags.FilterMipmap ) ... End End
and then in your code use
Local img:=Image.LoadMasked( path,maskPath )
So basically it’s possible the simplify code or resolve problem without changing everything from scratch or making derived class!
It is used to ‘link’ with external code (just see the source code of Monkey2 in many library like Bullet, JSon etc)
Officially – from Mark’s post – Class extensions allow you to add non-virtual methods (and other members except fields) to an existing class
Here you can read a bit more ‘useful’ example !