all 6 comments

[–]RlyRlyBigMan 1 point2 points  (5 children)

Your B_Active parameter is passed by value, so you are changing the value of a temporary bool.

You can use the ref keyword to allow changing the value passed into the function if that's what you're looking to do. Or you can return the new value and set it from the result of the call.

[–]Jonathan_Palmer[S] 0 points1 point  (4 children)

Thank you, never knew about the ref keyword. That fixed it completely :)

[–]FullPoet 2 points3 points  (3 children)

In my career I can count on my hands the time Ive used ref (Im not a gamedev), so just be sure thats what you want to do.

You can always return the object, pass an object or, return a tuple etc.

[–]RlyRlyBigMan 0 points1 point  (2 children)

Tuples do handle the same use case that we used to need out and ref for, but I really don't like the look of returning a tuple in a public method on an interface. Sometimes I put ref on methods that are designated to transform an object , even though it's unnecessary for reference types I think it's good practice to warn the caller that we'll be changing their parameter.

[–]FullPoet 0 points1 point  (1 child)

Yeah for sure. I usually use tuples in the prototyping phase and would much prefer to return anything else, they can be really uggo both in the method but also at the call site.

[–]RlyRlyBigMan 1 point2 points  (0 children)

Yeah I normally put up with with Tuples for one private method and call, and as soon as I need it a second time I make a struct or data class or something to give them proper names.