Comment Comment by whateveracct The monadic chaining section makes no mention of for-yield strangely enough. Their example def getAddress(name: String): Option[String] = { database.get(name).flatMap { elem => elem.data.get("address") .flatMap(Option.apply) // handle null value } } could just be def getAddress(name: String): Option[String] = { for { elem <- database.get(name) address <- elem.data.get("address") } yield address } and it's way more readable than their given rewrite.Then again, for-yield might be too magical and "can confuse programmers less familiar with Scala," which seems to be a reason for a lot of the stylistic decisions. parent whateveracct 11 years ago
Then again, for-yield might be too magical and "can confuse programmers less familiar with Scala," which seems to be a reason for a lot of the stylistic decisions.