-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I was also posting this in the do proposal:
tc39/proposal-do-expressions#9
To me, it sounds most logical that if any of the if
, switch
, for
, while
, try
keywords are used in an expression context, then it will be an implicit do expression construction:
So the following
const num = if (cond) {
100;
} else {
10;
};
would be equivalent to:
const num = do {
if (cond) {
100;
} else {
10;
}
}
Similarly, the following
const iterable = for (let user of users) {
if (user.name.startsWith('A'))
yield user;
}
would be equivalent to
const iterable = do* {
for (let user of users) {
if (user.name.startsWith('A'))
yield user;
}
};
leonardfactory, javierbyte, Flaque, tmarshall, lostpebble and 39 morebabakness
Metadata
Metadata
Assignees
Labels
No labels