| 09-29-2007, 09:37 AM | #1 |
JASS:struct blah integer i endstruct function blarg takes nothing returns nothing local blah b1 = blah.create() local blah b2 = blah.allocate() endfunction I'd just like to kindly ask what is the difference between .create() and .allocate() ? |
| 09-29-2007, 09:45 AM | #2 |
you can create a custom create method, there you have to you .allocate() to get a fresh new struct. JASS:struct blah integer i static method create takes integer i returns blah local blah b = blah.allocate() set b.i = i return b endmethod endstruct function blarg takes nothing returns nothing local blah b1 = blah.create(5) endfunction |
| 09-29-2007, 10:16 AM | #3 |
Oh I see, but what's the difference between them? |
| 09-29-2007, 10:23 AM | #4 |
allocate is private and can be used only inside struct methods. create is public and if there is no one it will be automatically created. allocate is dynamic method. create is static method. -- ups error, they are both static You can also exend create to give it your custom arguments, allocate cannot be changed. Allocate should be only used inside custom create method. The fact that you can do this: (use allocate outside of struct method) JASS:function blarg takes nothing returns nothing local blah b1 = blah.create() local blah b2 = blah.allocate() endfunction |
| 09-29-2007, 11:21 AM | #5 |
Oh I see, thank you then cohadar. Repped of course. |
| 09-29-2007, 01:09 PM | #6 |
allocate is private and it has always been private, thus the function in your first post is impossible to make. Edit: If you don't declare an static create method, then jasshelper makes one automatically for you, that just calls allocate() and is public. That's the difference. |
