The Curious Case of _; in Solidity

Jackson Ng
Coinmonks

--

Photo by Thought Catalog on Unsplash

Solidity as a programming language has been most intriguing for me because of its many features that I haven’t come across in languages that I have been more familiar with. One example is the underscore like the one in line 10 below.

The underscores _; that are found littered in Smart Contract source codes have invited questions from developers all over who are just beginning to code Smart Contracts. There has been many attempts to explain the _;. Find it here, here and here.

Jordan and I spoke about writing yet an article to explain what the _; does in Solidity just to enter the fray. So here’s my attempt…

Test this contract in Remix in a local JavaScript VM environment.

When _; Comes First

Here, we declare a modifier: conditionalChangeAtoThirty().

modifier conditionalChangeAtoThirty() {
_;
if (a == 20){

--

--