|
|
|
|
|
by _a_a_a_
1000 days ago
|
|
I have and do use this for my 'normal' code, but not very often. I tend to prefer breaking things up into functions (usually named, not lambdas). Where I do use this style extensively is in self-testing code: // set up data to be tested
var fred = ...
var cathy = ...
{ // check fred does something correctly
var result = fred.reproduce(2);
assert(result.length() == 2, "fred should have 2 children");
}
This prevents variable result from escaping and contaminating the next test, which happened an awful lot before I started doing this.Then maybe better ways; suggestions welcome. |
|