Pregunta

¿Cómo se vería esta clase en la f #?

public class myClass : baseClass
{
    public myClass()
    {
        this.someVariable = "test";
        this.someFunction();
    }
}

Hasta ahora he descubierto (es aún correcta?):

type myClass = class
        inherit baseClass
        new ()= 
            this.someFunction()
end

pero estoy luchando con llamar algunaFuncion () como se dice 'esto' no está definido

¿Fue útil?

Solución

He aquí una manera de traducir el código:

type baseClass() =
    member this.someFunction() = printf "hello world\n"

type myClass() as this =
    inherit baseClass()
    let mutable someVariable = "test"
    do this.someFunction()
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top