タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

Scalaに関するka2nnのブックマーク (2)

  • Eitherについてのメモ | blog.fly1ncu.com

    ScalaのEither型は2つの持ちうる型の代表となる型です。Left型かRight型のどちらかのインスタンスを持っています。例外がスローされる可能性がある処理などについて、このEither型でラップすることで、安全に、かつその後の処理を妨げない形で扱えるようになります。通常Right型には、処理が成功するなどで得られた正常な値を入れ、Left型には処理が失敗した原因など(Throwableやエラーメッセージなど)をいれます。 例えばStringOps#toIntはString型をInt型に変換するメソッドですが、このメソッドはInt型に変換できないときはNumberFormatExceptionをスローします。変換に成功した時にRight、失敗したときの例外をLeftに返すコードは以下のようになります def stringToInt(str: String) = { try { Ri

    ka2nn
    ka2nn 2013/07/12
  • MacRuby: The Definitive Guide

    Thank You! Open Feedback Publishing System (OFPS) is now retired. Thank you to the authors and commenters who participated in the program. OFPS was an O'Reilly experiment that demonstrated the benefits of bridging the gap between private manuscripts and public blogs. Readers gained access to in-progress O'Reilly manuscripts and were able to communicate suggestions with the authors, follow others'

    MacRuby: The Definitive Guide
    ka2nn
    ka2nn 2013/06/22
  • 1