Operator from Ethereum contract _;

Viewed 148

Sorry if it is duplicated question. What does "_" operator make?

This code is from Ethereum contract manual: https://ethereum.org/token#deploying

contract owned {
    address public owner;

    function owned() {
        owner = msg.sender;
    }

    modifier onlyOwner {
        if (msg.sender != owner) throw;
        _;
    }

    function transferOwnership(address newOwner) onlyOwner {
        owner = newOwner;
    }
}
2 Answers

It is used inside modifiers.

"The function body is inserted where the special symbol "_" in the definition of a modifier appears."

Reference: Contracts — Solidity 0.4.19 documentation

And in case it is used only once in a modifier, you can see it as following: After the return variables are assigned, the _ returns the control flow to what is next to the current modifier (next to the current modifier could be the next modifier or the function).

You can see a detailed explanation and example in the answer at: Are underscores _ in modifiers code or are they just meant to look cool?

Related