2020-05-12から1日間の記事一覧

Scala PlayframeworkのController、Actionとは?

PlayframeworkのControllerのメソッド、Action{}とはなんぞや?の整理。 def index() = Action{ implicit request => Ok("Hello World") } 自分なりの解釈なので、間違ってたらごめんなさい。 Actionの定義 Action.scalaのActionBuildertraitのapplyメソッド…

Scala traitの無名クラスmixin

絶対忘れるので書いておく。 traitのメソッドのみ使いたい場合、無名クラスにtrait mixinすれば簡単に利用できる。 このように対象のtraitがあった場合、 trait Job { def p(str:String) = {println(str); str} } ダメなケース。 new Job() traitそのものは…