| 12-28-2007, 11:56 AM | #1 |
Hi everyone. This question is pretty simple, I want to create a boolexpr from a struct method, is that possible? Example: JASS:struct MyStruct method MyStructFilter takes nothing returns boolean returns true endmethod static method create takes nothing returns MyStruct local MyStruct ms = MyStruct.allocate() local boolexpr b = Filter(function ms.MyStructFilter) // ... return ms endmethod endstruct Or: JASS:struct MyStruct method MyStructFilter takes nothing returns boolean returns true endmethod method MakeBoolExpr takes nothing returns nothing local boolexpr b = Filter(function .MyStructFilter) endmethod endstruct I know that these examples don't work and that the sintax is wrong, I just want you to see what I want to do. So, any ideas? I know I can make a function outside a struct that will be used by that boolexpr, I'm just asking if it's possible to make a "methody" one. |
| 12-28-2007, 01:05 PM | #2 |
static keyword is your friend. make MyStructFilter static and it'll all work as you desire. Keep in mind this will not be accessible. |
| 12-28-2007, 09:44 PM | #3 | |
Kewl.......but what keyword should I put? Method? Function? JASS:struct MyStruct static method MyStructFilter takes nothing returns boolean returns true endmethod static method create takes nothing returns MyStruct local MyStruct ms = MyStruct.allocate() local boolexpr b = Filter(method MyStruct.MyStructFilter) // ... return ms endmethod endstruct Like that? Quote:
Huh, what do you mean by that? |
| 12-28-2007, 10:00 PM | #4 |
The keyword 'this' wont be acceptable. You won't be able to use this.MyVariable (unless MyVariable is also static) inside your MyStructFilter function. |
