Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Databricks Scala Style Guide. Parent comment
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 }
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 -.-
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 -.-