Question

I wanna declare a record inside a class as follows:

class player (x, y)=
     object(self)
     type gun = {x:int; y:int; active:bool}
     val guns = Array.create 5 {x=0; y=0; active=false}
....

but the compiler claim that this line is syntax error : type gun = {x:in ....

when declared outside the class like this

type :  gun = {x:int; y:int; active:bool}
class player (x, y)=
     object(self)
     val guns = Array.create 5 {x=0; y=0; active=false}
....

the error is : unbound value gun.

so anyone know how to reach the same functionality with another way? thank you!

********* solved***

Bizare now it's working when the type is declared outside, thank you

Was it helpful?

Solution

Why don't you define the type gun outside of the class definition?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top