Top "For-comprehension" questions

for-comprehension is construction in Scala language allowing easy iteration over one or more collections.

Can I use for-comprehenion / yield to create a map in Scala?

Can I "yield" into a Map? I've tried val rndTrans = for (s1 <- 0 to nStates; s2 <- 0 to …

scala for-comprehension scala-2.7
What is the idiomatic way to pattern match sequence comprehensions?

val x = for(i <- 1 to 3) yield i x match { case 1 :: rest => ... // compile error } constructor cannot be instantiated …

scala pattern-matching for-comprehension
How to convert this map/flatMap into a for comprehension in Scala?

How to convert this map/flatMap into a for comprehension, and please explain how it works, thanks. def compute2(maybeFoo: …

scala monads for-comprehension
Getting the desugared part of a Scala for/comprehension expression?

Does anyone know how to get the (Scala part only) desugared translation of a for/comprehension expression before it actually …

scala syntactic-sugar for-comprehension
Method parameters validation in Scala, with for comprehension and monads

I'm trying to validate the parameters of a method for nullity but i don't find the solution... Can someone tell …

scala monads for-comprehension either
Ending a for-comprehension loop when a check on one of the items returns false

I am a bit new to Scala, so apologies if this is something a bit trivial. I have a list …

scala for-comprehension
Using for-comprehension, Try and sequences in Scala

Let's say you've got a bunch of methods: def foo() : Try[Seq[String]] def bar(s:String) : Try[String] and …

scala for-comprehension