19 Replies
out arguments must be assigned before the method returns
also the semantics indicate that the current value of the variable when called won't be used
ref must be assigned before the method is called
so something like
for ref
for out
ref is an input (and potentially an output), out is an output
so basically the function spawns a new value out of thin air
i don't know what that means
it doesn't spawn anything out of thin air, you're giving it a reference to a variable which it can assign a new value to
uhhh basically there were 0 values going into the function and 1 value coming out
the variable is declared and initialised inside the function though
no it's not
oh it isnt?
it's still a parameter, you have to pass an argument to the method
don't let the inline out variable declaration syntax fool you
is actually
aha ok
oh wait that makes it basically the same as ref no?
no
ref needs a value before going in?
it needs to be initialized, yes
with
out
the method is required to assign a value so it doesn't matter if it's initialized or notso this should be
i can't tell you what it should be, i don't know what your end goal is
oh alright
i personally rarely use ref, it's only applicable when working with large structs or you need to change the value of a variable that's being passed in
ooo alright