arbitrary type array ocaml

View: New views
1 Messages — Rating Filter:   Alert me  

arbitrary type array ocaml

by blah2341 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm trying to create a class that stores an array of any type (all the same type, but that type is unknown to this class). I am using the following code...

class objectArray =
 object (self)
        val mutable baseArray = Array.create 10;
        val mutable lastIndex = 0;
        method length =
                let arrLength = Array.length baseArray in
                arrLength
 end;;

But I get this error "This expression has type 'a -> 'a array but is here used with type 'b array"

I can't do Array.create with anything but 'a because I don't know what type it will be. Any suggestions?