Scala Tutorialsを読む 9 Method definition

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

今日は 9 Method definition メソッドの定義について

  • In Scala methods are defined using def
  • Scalaではメソッドはdefを使って定義されます
  • Methods that return a value must have an equal sign before the body of the method
  • メソッドが値を返すときはメソッドの本体の前でイコールを使って指定する必要があります
  • Methods that have either a return statement or are recursive must declare a return type
  • メソッドはリターンステートメントを持つかまたは、再帰的なメソッドは戻り値の型を宣言する必要があります。