#Is there a way to instantiate a struct from a function but call a method on the struct before?

1 messages · Page 1 of 1 (latest)

stark root
#

I am sorry but this isnt the easiest to phrase lol

Ye, as far as I know the only was to return a struct is in the return statement itself, so Im wondering if there might be a way to sort of create the struct at the return adress and then call a method on it, or to call a structs method in its declaration itself?

honest flame
#

Do you mean something like this?

var instance = Struct.init();
instance.someFunction();
return instance;
honest shell
#

If you don't have any self-referential pointers, QuantumDeveloper's answer should work fine

#

But since you specifically mentioned result locations, I'm guessing you do

stark root
stark root
honest shell
#

no

stark root
#

well that would require what i asked in the first place lol