Skip to main content
added 126 characters in body
Source Link

This boils down to the difference between the "fetch!" and "fetches" at the dog park. Respectively an order and a statement.

"return X" is an imperative AKA an order. Like in linguistics, it says "you (your function) better return that thing that needs returning and that's an order!".

This order is generally found at the very end of a function and means "now that you're done processing X, return it to whatever line of code called this function you're currently in".

Meanwhile, "returns X" is a declarative AKA a statement of a fact. Like in linguistics, it is a statement that "this thing (your function) is expected to return something once it's done doing its thing.

This statement is found in the declaration of a function (your very first line of code) and means "once done, this function returnsreturns one or more things of the following types to whoever called this function"function in the first place".

So if you're declaring a function and you want whoever reads your code (including and especially your future self) to know at a glance what this function returnsreturns, then declare/state itwhat that returned thing is right at the top:

function myFunction 
returns (
typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction
) 
{ 
blah blah blah the body of my function goes here, don't forget the semi-colon; 
}

To actually returncause the thingfunction to return the thing that this function returnsis supposed to return, you issue an order by telling the function "hey, function, return the thing I want you to return!" as follows:

function myFunction 
returns (
typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction
) 
{
return easyToUnderstandNameOfMyThingReturnedByThisFunction;
}

Example:

/* My function returnS a uint called theNumberFour which is probably the number 4 */
function myFunction returns (uint theNumberFour) {
/* "Hey, function, please return the number 4" */
return 4;
}

This boils down to the difference between the "fetch!" and "fetches" at the dog park. Respectively an order and a statement.

"return X" is an imperative AKA an order. Like in linguistics, it says "you (your function) better return that thing that needs returning and that's an order!".

This order is generally found at the very end of a function and means "now that you're done processing X, return it to whatever line of code called this function you're currently in".

Meanwhile, "returns X" is a declarative AKA a statement of a fact. Like in linguistics, it is a statement that "this thing (your function) is expected to return something once it's done doing its thing.

This statement is found in the declaration of a function and means "once done, this function returns one or more things of the following types to whoever called this function".

So if you're declaring a function and you want whoever reads your code (including and especially your future self) to know at a glance what this function returns, then declare/state it:

function myFunction 
returns (
typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction
) 
{ 
blah blah blah the body of my function goes here, don't forget the semi-colon; 
}

To actually return the thing the thing that this function returns, you issue an order by telling the function "hey, function, return the thing I want you to return!" as follows:

function myFunction 
returns (
typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction
) 
{
return easyToUnderstandNameOfMyThingReturnedByThisFunction;
}

Example:

/* My function returnS a uint called theNumberFour which is probably the number 4 */
function myFunction returns (uint theNumberFour) {
/* "Hey, function, please return the number 4" */
return 4;
}

This boils down to the difference between the "fetch!" and "fetches" at the dog park. Respectively an order and a statement.

"return X" is an imperative AKA an order. Like in linguistics, it says "you (your function) better return that thing that needs returning and that's an order!".

This order is generally found at the very end of a function and means "now that you're done processing X, return it to whatever line of code called this function you're currently in".

Meanwhile, "returns X" is a declarative AKA a statement of a fact. Like in linguistics, it is a statement that "this thing (your function) is expected to return something once it's done doing its thing.

This statement is found in the declaration of a function (your very first line of code) and means "once done, this function returns one or more things of the following types to whoever called this function in the first place".

So if you're declaring a function and you want whoever reads your code (including and especially your future self) to know at a glance what this function returns, then declare/state what that returned thing is right at the top:

function myFunction 
returns (
typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction
) 
{ 
blah blah blah the body of my function goes here, don't forget the semi-colon; 
}

To actually cause the function to return the thing that this function is supposed to return, you issue an order by telling the function "hey, function, return the thing I want you to return!" as follows:

function myFunction 
returns (
typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction
) 
{
return easyToUnderstandNameOfMyThingReturnedByThisFunction;
}

Example:

/* My function returnS a uint called theNumberFour which is probably the number 4 */
function myFunction returns (uint theNumberFour) {
/* "Hey, function, please return the number 4" */
return 4;
}
added 68 characters in body
Source Link

This boils down to the difference between the "fetch!" and "fetches" at the dog park. Respectively an order and a statement.

"return X" is an imperative AKA an order. Like in linguistics, it says "you (your function) better return that thing that needs returning and that's an order!".

This order is generally found at the very end of a function and means "now that you're done processing X, return it to whatever line of code called this function you're currently in".

Meanwhile, "returns X" is a declarative AKA a statement of a fact. Like in linguistics, it is a statement that "this thing (your function) is expected to return something once it's done doing its thing.

This statement is found in the declaration of a function and means "once done, this function returns one or more things of the following types to whoever called this function".

So if you're declaring a function and you want whoever reads your code (including and especially your future self) to know at a glance what this function returns, then declare/state it:

function myFunction  
returns ( 
typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction 
)  
{  
blah blah blah the body of my function goes here, don't forget the semi-colon; 
}

To actually return the thing the thing that this function returns, you issue an order by telling the function "hey, function, return the thing I want you to return!" as follows:

function myFunction 
returns (
typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction
) 
{
return easyToUnderstandNameOfMyThingReturnedByThisFunction;
}

Example:

/* My function returnS a uint called theNumberFour which is probably the number 4 */
function myFunction returns (uint theNumberFour) {
/* "Hey, function, please return the number 4" */
return 4;
}

This boils down to the difference between the "fetch!" and "fetches" at the dog park. Respectively an order and a statement.

"return X" is an imperative AKA an order. Like in linguistics, it says "you (your function) better return that thing that needs returning and that's an order!".

This order is generally found at the very end of a function and means "now that you're done processing X, return it to whatever line of code called this function you're currently in".

Meanwhile, "returns X" is a declarative AKA a statement of a fact. Like in linguistics, it is a statement that "this thing (your function) is expected to return something once it's done doing its thing.

This statement is found in the declaration of a function and means "once done, this function returns one or more things of the following types to whoever called this function".

So if you're declaring a function and you want whoever reads your code (including and especially your future self) to know at a glance what this function returns, then declare/state it:

function myFunction returns (typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction) { blah blah blah the body of my function goes here }

To actually return the thing the thing that this function returns, you issue an order by telling the function "hey, function, return the thing I want you to return!" as follows:

function myFunction 
returns (
typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction
) 
{
return easyToUnderstandNameOfMyThingReturnedByThisFunction;
}

Example:

/* My function returnS a uint called theNumberFour which is probably the number 4 */
function myFunction returns (uint theNumberFour) {
/* "Hey, function, please return the number 4" */
return 4;
}

This boils down to the difference between the "fetch!" and "fetches" at the dog park. Respectively an order and a statement.

"return X" is an imperative AKA an order. Like in linguistics, it says "you (your function) better return that thing that needs returning and that's an order!".

This order is generally found at the very end of a function and means "now that you're done processing X, return it to whatever line of code called this function you're currently in".

Meanwhile, "returns X" is a declarative AKA a statement of a fact. Like in linguistics, it is a statement that "this thing (your function) is expected to return something once it's done doing its thing.

This statement is found in the declaration of a function and means "once done, this function returns one or more things of the following types to whoever called this function".

So if you're declaring a function and you want whoever reads your code (including and especially your future self) to know at a glance what this function returns, then declare/state it:

function myFunction  
returns ( 
typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction 
)  
{  
blah blah blah the body of my function goes here, don't forget the semi-colon; 
}

To actually return the thing the thing that this function returns, you issue an order by telling the function "hey, function, return the thing I want you to return!" as follows:

function myFunction 
returns (
typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction
) 
{
return easyToUnderstandNameOfMyThingReturnedByThisFunction;
}

Example:

/* My function returnS a uint called theNumberFour which is probably the number 4 */
function myFunction returns (uint theNumberFour) {
/* "Hey, function, please return the number 4" */
return 4;
}
Source Link

This boils down to the difference between the "fetch!" and "fetches" at the dog park. Respectively an order and a statement.

"return X" is an imperative AKA an order. Like in linguistics, it says "you (your function) better return that thing that needs returning and that's an order!".

This order is generally found at the very end of a function and means "now that you're done processing X, return it to whatever line of code called this function you're currently in".

Meanwhile, "returns X" is a declarative AKA a statement of a fact. Like in linguistics, it is a statement that "this thing (your function) is expected to return something once it's done doing its thing.

This statement is found in the declaration of a function and means "once done, this function returns one or more things of the following types to whoever called this function".

So if you're declaring a function and you want whoever reads your code (including and especially your future self) to know at a glance what this function returns, then declare/state it:

function myFunction returns (typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction) { blah blah blah the body of my function goes here }

To actually return the thing the thing that this function returns, you issue an order by telling the function "hey, function, return the thing I want you to return!" as follows:

function myFunction 
returns (
typeOfMyThingReturnedByThisFunction easyToUnderstandNameOfMyThingReturnedByThisFunction
) 
{
return easyToUnderstandNameOfMyThingReturnedByThisFunction;
}

Example:

/* My function returnS a uint called theNumberFour which is probably the number 4 */
function myFunction returns (uint theNumberFour) {
/* "Hey, function, please return the number 4" */
return 4;
}