Menu
  • HOME
  • TAGS

why yield can not work with while loop in scala

scala,yield-keyword

Because a while loop is a java equivalent while loop, and the 'for loop' is translated to function call of: <IndexedSeq>.map (if you use yield) or <IndexedSeq>.foreach (if you don't care the result). Example Scala Code: class ForVsWhileLoop { val dummy = for(i <- 1 to 10) yield i var...

When should I use yield and when yield* with Koa.js

javascript,node.js,ecmascript-6,koa,yield-keyword

This article - yield next vs. yield* next , from one of koa's team members, explains exactly what this is and why they use it. There are a few cases where one could use this yield *, as the articles shows, for avoiding extra co calls, or keeping the context...