Create a byte array with dynamic size in F#

前端 未结 4 1847
被撕碎了的回忆
被撕碎了的回忆 2021-02-20 07:16

In C# and Java a byte array can be created like this

byte[] b = new byte[x];

where x denotes the size of the array. What I want to

4条回答
  •  星月不相逢
    2021-02-20 07:27

    What do you mean?

    F# has a syntax different from C# and Java, you are using the Array module to let him create an array with an initializer. Nothing strange, one language is functional while the other is imperative so these differences are indeed needed.

    According to the F# language specs you can't declare something that is uninitialized (unless using specific patterns as the Option type which are just exploits that allow you to express the uninitialized concept without really having it), that's why you have to pass an initializer for elements in the array.

提交回复
热议问题