News for hackers. Stuff that matters.
Re:Databricks Scala Style Guide by whateveracct on Tuesday March 17, 2015 @03:03PM (#9220417)
Good point I was sloppy in my reading.

    def getAddress(name: String): Option[String] = {
      for {
        elem <- database.get(name)
        nullableAddress <- elem.data.get("address")
        address <- Option(nullableAddress)
      } yield address
    }

    def getAddress(name: String): Option[String] = {
      for {
        elem <- database.get(name)
        address <- elem.data.get("address").flatMap(Option.apply)
      } yield address
    }
are both still better though.

Also it seems like a bit of a strawman to use such a pathological example (null values stored in a map are frowned upon even in Java-land) to motivate the entire styleguide section about monadic chaining. They say it's contrived but still -.-

Re:Databricks Scala Style Guide by ilikerps on Tuesday March 17, 2015 @05:29PM (#9221652)
Note that while frowned upon, such issues arise altogether more often than they should in real systems.