2 ms·
What's the benefit over myBlock() and otherBlock()
by int_19h 8y ago
What's the benefit over myBlock() and otherBlock()
- austincheney 8y agoYou can write code withou the curly braces, but is generally considered a bad practice. if (expression) myBlock() else otherBlock() is really if (expression) {myBlock();} else {otherBlock();} In that case a block is still there and not reused. Both the semantics and structure are different if the block itself were reused. You could extend the above like so: if (expression) {myBlock();x+=1;} else {otherBlock();} If instead the block were reused that would not work. A finer degree of separation is imposed by reference that reenforces separated structures by name. Separation is the foundation of simplicity. It also makes for code that is easier to read like a natural language sentence.
- int_19h 8y agoI'm still not following. Why would you want to reuse blocks (scopes?) rather than code?