Skip to content

Instantly share code, notes, and snippets.

@gabu
Created May 16, 2012 03:16
Show Gist options
  • Save gabu/2707046 to your computer and use it in GitHub Desktop.
Save gabu/2707046 to your computer and use it in GitHub Desktop.
【Scala】Play 2.0 Scala で Option のネストを綺麗にしたい【初心者】
def gabu(id: String, bid: String) = Action {
Project.findOneByID(id) match {
case Some(project: Project) => Build.findOneByID(new ObjectId(bid)) match {
case Some(build: Build) =>
// etc...
Ok(views.html.gabu(build)
case None => NotFound
}
case None => NotFound
}
}
@gabu
Copy link
Author

gabu commented May 16, 2012

うおお、こんな書き方もできるんですね。

そうなんです。サンプルだとprojectを使ってないコードになってしまっていますが、
実際のコードはprojectを引き継いで使いたいのでツッコミ非常にありがたいです。

正常系、異常系が読みやすくなっていいですね!

アドバイスありがとうございます><

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment