Revision 2 as of 2011-10-28 06:07:44

Clear message
Locked History Actions

scala/import

import

オブジェクトのインポート

オブジェクトをインポートすることで、そのオブジェクトを指定しなくともメンバにアクセスできるよになる

class Foo {
  val field = 123
}
object Main {  
  def main(args: Array[String]) {
    val foo = new Foo
    import foo._
    println(field)
  }
}

結果は

123

== trait