On 4 December 2013 10:13, Olov Lassus <[email protected]> wrote:
> I wanted to do
>
> if (const val = compute(something)) {
> // ...
> }
>
> but I had to do
>
> let val;
> if (val = compute(something)) {
> // ...
> }
>
> which is unfortunate not only because val leaks to the outer scope but also
> because let suggest that the binding mutates (which it technically does, but
> practically doesn't).
I don't understand. Why can't you do
const val = compute(something)
if (val) {
// ...
}
instead? Or, if you also want to address the other half of your
concern, use an additional block (which admittedly is more verbose).
/Andreas
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss