1

In Solidity, this sentence:

(bool sent, ) = msg.sender.call{value: _amount}("");

What is the sense of that "," after sent variable?

Any link to offcial documentation?

Many thanks.

0

address.call returns two things: the status of the call (as a boolean), and the returned data of the call (as bytes), in the form of a tuple. The type looks something like (bool success, bytes data).

This is a destructuring assignment, as mentinoned by Richard Horrocks in the comments:

(bool foo, bytes bar) = someFunction()

It takes the values in the returned tuple, and assigns them to the variables foo and bar. If someFunction returns two (or more) values in the tuple, but we only care about the first one, we can write it as:

(bool foo, ) = someFunction()

In which case we are not assigning the second variable. Doing this can potentially save some gas. Note that the other way around is also possible:

(, bytes bar) = someFunction()
  • Thanks a lot for your great explanation!!! Very clear. – Kevin Flynn Jan 12 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.