Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to declare a list inside a type declaration in F#

Tags:

list

f#

I'm learning F# from just a few days, so here's a newbie question:

I've learn to declare a new type this way:

type GameEntity = 
    {
        Position : Vector3<m>
        Velocity : Vector3<m/s>
        Acceleration : Vector3<m/s^2>
    }

(Vector3 and Meausure are declared somewhere else.. this works fine). Now I would like to declare another type that stores inside it a list of GameEntity. I tried something like this:

type GameWorld = 
    {
        name : string;
        entities : GameEntity = []   //error
    }

Could someone show me the right syntax to declare a list(entities) of a previous defined type (GameEntity) ?

like image 401
Heisenbug Avatar asked Nov 14 '11 14:11

Heisenbug


1 Answers

You can use:

entities : GameEntity list

or

entities : List<GameEntity>
like image 71
Vitaliy Avatar answered Nov 15 '22 15:11

Vitaliy