LoginSignup
0
0

More than 5 years have passed since last update.

Scalaにおける型パラメータ基本構文

Last updated at Posted at 2017-12-10

概要

Scalaで型パラメータ(ジェネリクス)という仕組みの基本構文について。

構文

  • クラス|ケースクラス
    ※ ケースクラスの場合はcaseキーワードを付けるだけ
class クラス名[ 型パラメ−タ ]( 引数名: 型パラメ−タ ) {
  def メソッド名( 引数名: 型パラメ−タ ): 戻り型 = { 処理 }
}
  • トレイト
trait トレイト名[ 型パラメ−タ ] {
  def メソッド名( 引数名: 型パラメ−タ ): 型パラメ−タ = { 処理 }
}

class 利用クラス名 extends トレイト名 {
  def メソッド名( 引数:  ): 戻り型 = { 処理 }
}
  • メソッド
def メソッド名[ 型パラメ−タ ]( 引数名:  ): 戻り型 = { 処理 }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0