If this then that
Let's have a closer look at this allInitialOwnersAssigned()
function we just looked at. It's fairly simple:
address owner = 0xC352B534e8b987e036A93539Fd6897F53488e56a;allPunksAssigned = true;function allInitialOwnersAssigned() { if (msg.sender != owner) throw; allPunksAssigned = true;}
In here, we find a new piece of code we haven't seen yet; an "if" statement. Programs typically interpret and run one statement after another. But the type of programs we can build with just linear flow is very limited. That's why we have these special things that control the flow of our program and make it behave differently depending on context.
If we call the function as LarvaLabs, we assign the variable allPunksAssigned
to true
. If anyone else calls the function, it throws an error and the transaction is reverted.
Note that these if
statements can be nested for more complex decision trees.
But we're already getting too much in the nitty gritty...
Let's contine with loops!