0

example:

 function proceed() returns (bool success) {

if (msg.sender != owner) return false;

        return important_function();
    }

So important_function shouldn't be reached if msg.sender isn't owner (condition above returns false). This will give bad jump dest or revert, correct? Thanx!

2

Does returning false prevent bool function from further execution in Solidity?

Returning any value prevents any function in (probably) every language from further execution.

This will give bad jump dest or revert, correct?

No, not correct:

  • revert and require(<an expression which evaluates to false>) will revert the transaction with a REVERT opcode
  • assert(<an expression which evaluates to false>) and a few other scenarios (such as accessing an array at an illegal index) will revert the transaction with an INVALID opcode
  • return false will NOT revert the transaction
| improve this answer | |

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.