I have this,
function*(a){
if (a) {
yield API.callRoute();
return;
}
// other stuff that is blocked by return
}
I want this:
function*(a){
if (a) {
return yield API.callRoute(); // one fewer line of code
}
//...
}
Doable? Why? Why not?
Yes, it's doable, but your second snippet return
s the result of the yield
expression. If you don't want that but make it exactly equivalent to your first snippet, use
return void yield API.callRoute();
though probably it's not worth making this a line shorter when the difference is significant.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.