0

I am a beginner python programmer, and trying to understand a c# script. I came across the out keyword, I have read several other threads, but I think i have not been able to understand it completely. So here's a snippet of the script I am trying to understand.

void Vector3(out NewVector3 v) {
    double x, y, z; 
    Double(out x);
    Double(out y);
    Double(out z);
    v = NewVector3(x, y, z);

A python equivalent of this snippet based on my understanding would be,

def Vector3():
    return NewVector(float(),float(),float())

is my translation correct?

1 Answers1

-2

out is used in languages that can't return multiple objects; you pass in a complex object for the function to 'return' by altering the contents.

In Python, just return multiple values (a tuple, really), or in this case, an instance of the NewVector() class:

return NewVector(0., 0., 0.)
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343