Skip to content

Instantly share code, notes, and snippets.

@j5ik2o
Created October 19, 2011 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j5ik2o/1297960 to your computer and use it in GitHub Desktop.
Save j5ik2o/1297960 to your computer and use it in GitHub Desktop.
Scala - クラス
package money
import java.util.Currency
class Money(amnt : BigDecimal, creny : Currency){
val amount = amnt // フィールド宣言
val currency = creny // フィールド宣言
// フィールド宣言でありながら、コンストラクタのボディとなっているので、処理も書けます。
}
// 上記は下記のように省略して記述できる。
class Money(val amount : BigDecimal, val currency : Currency)
val currency = Currency.getInstance("JPY")
val money = new Money(100, currency)
println(money.amount)
println(money.currency)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment