What are the differences in these two? ..() .=..()
Why would I want to do one of them over the other?
ID:265696
![]() Feb 3 2007, 8:26 am
|
|
![]() Feb 3 2007, 8:39 am
|
|
..() simply calls the parent procedure. . is the default value returned whenever a procedure finishes. . = ..() sets the default return value to the parent procedure.
|
Prodigal Squirrel wrote:
What are the differences in these two? ..() .=..() "..()" calls the parent proc. "." is the return value for this proc. If your proc reaches the end without encountering a return statement, it returns the value stored in ".". When you use ". = ..()", that says "Do the default or parent proc and store its result in . so that this proc will return the same value." This proc: Move() is equivalent to Move() |
Popisfizzy wrote:
..() simply calls the parent procedure. . is the default value returned whenever a procedure finishes. . = ..() sets the default return value to the parent procedure. More accurately, .=..() runs the parent procedure, and uses its return value as the default. There's a subtle distinction. The way you said it could mean this, or it could mean that the default if nothing else is returned is to call ..() at the last minute and use that instead. Lummox JR |
Since everybody kinda went the technical route, I'll explain in Plain Jane English.
..() with no dot in front of it means that you want to run the parent procedure, but that you don't care about the parent procedure's return value. For instance: mob In this case, the /mob/parent/child/MyProc() will return 0, not 1, as the parent proc's return value was simply discarded. Without writing return at the end, the /mob/parent/child/MyProc() has an implied return .. If we changed the line ..() . = ..() The output in both cases would still be: Parent proc! Child proc! (Technically speaking, /mob/parent/child/MyProc() in the ..() case will return null, not 0, but the distinction isn't important here. ;-)) |