Pages

Thursday, May 17, 2012

Self Note: Seq and base class call


put the following code in a F# app. notice there is an error under let a. the error is "A protected member is called or 'base' is being used. This is only allowed in the direct implementation of members since they could escape their object scope." 

type BaseClass() =
    member val X = 0 with get, set

type ClassA() =
    inherit BaseClass()
    member this.F() =
        let r = seq {
            let a = 0
            let b = base.X
            yield a }
        r

The fix is to change base to this. 

No comments: