エントリーの編集

エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
Rubyスタイルの後置rescueをScalaで実現する - Hello, world! - s21g
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています

- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
Rubyスタイルの後置rescueをScalaで実現する - Hello, world! - s21g
1 class Rescueable[A](a: => A) { 2 def rescue[B](b: => B) = try{a}catch{case _ => b} 3 } 4 5 ... 1 class Rescueable[A](a: => A) { 2 def rescue[B](b: => B) = try{a}catch{case _ => b} 3 } 4 5 implicit def anyToRescueable[A](a: => A) = new Rescueable(a) 6 7 println("12341234".toLong rescue 0) // => 12341234 8 println("1234x1234".toLong rescue 0) // => 0