Created
May 16, 2012 03:16
-
-
Save gabu/2707046 to your computer and use it in GitHub Desktop.
【Scala】Play 2.0 Scala で Option のネストを綺麗にしたい【初心者】
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
うおお、こんな書き方もできるんですね。
そうなんです。サンプルだとprojectを使ってないコードになってしまっていますが、
実際のコードはprojectを引き継いで使いたいのでツッコミ非常にありがたいです。
正常系、異常系が読みやすくなっていいですね!
アドバイスありがとうございます><