for-comprehension

Understanding Scope on Scala's For Loops (For Comprehension)

In Chapter 3 of Programming Scala, the author gives two examples of for loops / for comprehensions, but switches between using ()'s and {}'s. Why is this the case, as these inherently look like they're doing the same thing? Is there a reason breed <- dogBreeds is on the 2nd line in example #2? // #1 ()'s for (breed <- dogBreeds if b...

Scala for comprehensions and partial map

The Scala language specification section 6.19 says: A for comprehension for (p <- e) yield e0 is translated to e.map { case p => e0 } So... scala> val l : List[Either[String, Int]] = List(Left("Bad"), Right(1)) l: List[Either[String,Int]] = List(Left(Bad), Right(1)) scala> for (Left(x) <- l) yield x res5: List[String] = List(Bad)...

Scala "<-" for comprehension

Hello guys, I have found that Scala always has a "natural explanation" to anything. Always something like "ohh, but that's just a function being called on this and that object with this and that parameter". In a sense, nothing is really compiler-magic as we know it from other languages. My question is on the <- operator as used in the ...