Skip to content

Instantly share code, notes, and snippets.

@ozw-sei
Created February 17, 2013 17:08
Show Gist options
  • Save ozw-sei/4972316 to your computer and use it in GitHub Desktop.
Save ozw-sei/4972316 to your computer and use it in GitHub Desktop.
Scala勉強中@コップ本 クラス ref: http://qiita.com/items/65760454415aba9c1e94
//クラス定義
class SampleClass{
//何も書かないとpublic参照
var num =0
}
//インスタンス生成
val tmp = new SampleClass
//値変更
tmp.num = 1
//valなので、最代入できません。
tmp = new SampleClass
//定義
class Vector2 {

private var x:Int
private var y:Int
}
//インスタンス生成
val pos = new Vector2
pos.x //アクセスエラー
pos.y //アクセスエラー
//シングル
object test{
def disp() = print("Hello,World")
}
//オブジェクト名から呼び出し
test.disp()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment