Tech Tip: Two Ways to Assign the Output of a Project Method
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: September 26, 2025
When writing a project method, there are a couple ways to assign the value of its output:
a) Assigning a value to the declared return parameter
b) Using a return statement
Both examples above function similarly in outputting the same value, though (a) has the added benefit of type checking. Note that (b) stops execution of the method, while (a) does not necessarily. If both were to be used in the same method, (b) would always take precedence over (a) to produce the output.
a) Assigning a value to the declared return parameter
#DECLARE($input : Text)->$output : Text $msg:=$input+"foobar" $output:=$msg |
b) Using a return statement
#DECLARE($input : Text) : Text $msg:=$input+"foobar" return $msg |
Both examples above function similarly in outputting the same value, though (a) has the added benefit of type checking. Note that (b) stops execution of the method, while (a) does not necessarily. If both were to be used in the same method, (b) would always take precedence over (a) to produce the output.