Scala Tutorialsを読む 13 Anonymous Functions 2

http://scalatutorials.com/tour/interactive_tour_of_scala_anonymous_functions_2.html

今日は、13 Anonymous Functions 2 を読みます。今日といいつつ今日は14日なので1日忘れてしまったので、2日分書かないといけない。

The first example is a method definition as we've seen before The second, 最初の例はメソッドの定義です我々が前の2つで見た、 is like the previous slide, only assigned to a val, this is very, very roughly like the difference between これは前のスライドのようで、valで割り当てしただけで、これはとても大ざっぱに言うとJavaScriptの以下の違いに似ています。

function foo(x, y) {
  return x + y;
}

and と

var foo = function(x, y) {
  return x + y;
}

in JavaScript.

The third, was briefly demonstrated in the previous slide, uses the shorter _ placeholder syntax. 三つ目は前のスライドでさらっとデモしていて、_の短いプレースホルダ構文を使ってます。 However the usage on the left is rare in Scala, 一方で、左の使い方はScalaではレアで、 the _ notation for anomymous functions is mostly useful when _記法の無名関数は高階関数(他の関数を受け取るか返す関数)にパラメータとして渡す時によく使われます。