How to declare an entry inside the OCAML class

I want to declare an entry inside the 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 claims that this line is a syntax error: type gun = {x: in ....

if declared outside of a class such as

 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} .... 

error: unbound gun.

so that anyone knows how to achieve the same functionality in a different way? thanks!

********* resolved ***

Bizare now works when a type is declared outside, thanks

+4
source share
1 answer

Why do not you determine the type of gun outside the class definition?

+2
source

All Articles