|
|
|
|
|
by Izkata
1126 days ago
|
|
And a step further into the past, no need for a lambda - I find this clearer: function doWork() {
function calcX() {
if (foo()) return f();
if (bar()) return g();
return h();
}
return calcX() * 10;
}
Where "calc" can be "gen[erate]" or "find" or at least more descriptive. |
|
Part of the beauty of `run` is that you don't have to declare and name a function `calcX`. In longer and more complex examples, declaring a function inline like this is potentially confusing because you don't get to see where it is used, whereas with `run` you assign the return value immediately to a variable.