May a while loop be used with yield in scala

前端 未结 3 855
梦毁少年i
梦毁少年i 2021-02-04 06:22

Here is the standard format for a for/yield in scala: notice it expects a collection - whose elements drive the iteration.

for (blah <- blahs) yield someThi         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-04 07:01

    Using for comprehensions is the wrong thing for that. What you describe is generally done by unfold, though that method is not present in Scala's standard library. You can find it in Scalaz, though.

提交回复
热议问题