views:

134

answers:

2

In C# I'd write something like

MyType arr = new MyType[10];

to alloc arr as array which has 10 items of type MyType.

How to do the same in F# ??

let mutable arr = ?????????????
+2  A: 

You could conceivably be interested in this discussion although it is in an OCaml context.

Pascal Cuoq
Thanks, Pascal. :-)
DinGODzilla
+4  A: 

To initialise the array to the default (e.g. null or zero), use Array.zeroCreate:

let arr : int array = Array.zeroCreate 10

To initialise with a value, use Array.init.

itowlson
Thanks, this is just it.
DinGODzilla
Note also 'Array.create' and 'Array.init', see the docs: http://msdn.microsoft.com/en-us/library/ee370273(VS.100).aspx
Brian