Jean Pierre Dudey
Jean Pierre Dudey

Reputation: 665

What is the purpose of the "ref" and "out" keywords in Vala?

How and when should these keywords be used?

Do they have the same purpose as in C#?

Upvotes: 1

Views: 918

Answers (1)

Mike Chamberlain
Mike Chamberlain

Reputation: 42510

The documentation suggests they are exactly the same as in C#:

  • 'out' from the caller side: you may pass an uninitialised variable to the method and you may expect it to be initialised after the method returns
  • 'out' from callee side: the parameter is considered uninitialised and you have to initialise it
  • 'ref' from caller side: the variable you're passing to the method has to be initialised and it may be changed or not by the method
  • 'ref' from callee side: the parameter is considered initialised and you may change it or not

Upvotes: 8

Related Questions