TriggerHappy
...
- Reaction score
- 341
This is just an example for people who want to code in a more OOP style.
With the example included, things like this are possbile;
You can make a wrapper for almost anything.
It's basically just a bunch of pointers.
This is not a script submission therefore I am not writing any documentation on this.
It's meant to just show you that it can be done fairly easily and is for the people who enjoy writing in OOP.
Yes it probably has been known for a long time but this was inspired by someone asking about nested structs and I decided that it may not be common knowledge.
With the example included, things like this are possbile;
JASS:
You can make a wrapper for almost anything.
It's basically just a bunch of pointers.
JASS:
library VariableWrapper initializer onInit
private struct StringEx
static method Print takes string s returns nothing
call BJDebugMsg(s)
endmethod
endstruct
private struct IntEx
static string s
method Print takes nothing returns nothing
call BJDebugMsg(IntEx.s)
set IntEx.s = ""
endmethod
method toString takes nothing returns IntEx
set IntEx.s = I2S(this)
return 0
endmethod
endstruct
struct Var
static StringEx String
static method Int takes integer i returns IntEx
return i
endmethod
endstruct
endlibrary
This is not a script submission therefore I am not writing any documentation on this.
It's meant to just show you that it can be done fairly easily and is for the people who enjoy writing in OOP.
Yes it probably has been known for a long time but this was inspired by someone asking about nested structs and I decided that it may not be common knowledge.