Dirac
22710180
- Reaction score
- 147
I've come up with a very odd need:
Lets say I have 3 structs that share the same allocator and each one has a method with the same name as the other two, takes the same arguments, but does different things.
Is there a way to change the type of the instance so it would call other's struct's method?
Example:
Imagine I have a instance of type "Addition" named "this", when I call this.math(3) it adds 3 to value[this] but then I want to substract or multiply it by another value without having to type the struct's name? As in
[ljass]call this.math(5)[/ljass] would now result in substraction or multiplication
Lets say I have 3 structs that share the same allocator and each one has a method with the same name as the other two, takes the same arguments, but does different things.
Is there a way to change the type of the instance so it would call other's struct's method?
Example:
JASS:
globals
real array value
endglobals
struct Addition extends array
method math takes real v returns nothing
set value[this] = value[this] + v
endmethod
endstruct
struct Substraction extends array
method math takes real v returns nothing
set value[this] = value[this] - v
endmethod
endstruct
struct Multiplication extends array
method math takes real v returns nothing
set value[this] = value[this] * v
endmethod
endstruct
Imagine I have a instance of type "Addition" named "this", when I call this.math(3) it adds 3 to value[this] but then I want to substract or multiply it by another value without having to type the struct's name? As in
[ljass]call this.math(5)[/ljass] would now result in substraction or multiplication