サーチ…


クラスの宣言

// class declaration with a list of parameters for a primary constructor
type Car (model: string, plates: string, miles: int) =    

    // secondary constructor (it must call primary constructor)
    new (model, plates) = 
        let miles = 0
        new Car(model, plates, miles)
    
    // fields
    member this.model = model
    member this.plates = plates
    member this.miles = miles

インスタンスの作成

let myCar = Car ("Honda Civic", "blue", 23)
// or more explicitly
let (myCar : Car) = new Car ("Honda Civic", "blue", 23)


Modified text is an extract of the original Stack Overflow Documentation
ライセンスを受けた CC BY-SA 3.0
所属していない Stack Overflow