The return statement

Returning data is an integral part of a Solidity function. Solidity provides two different syntaxes for returning data from a function. In the following code sample, two functions—getBlockNumber and getBlockNumber1—are defined. The getBlockNumber function returns a uint without naming the return variable. In such cases, developers can resort to using the return keyword explicitly to return from the function.

The getBlockNumber1 function returns uint and also provides a name for the variable. In such cases, developers can directly use and return this variable from a function without using the return keyword as shown in the following screenshot:

Get Solidity Programming Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.