let source = [|(CocaCola, bigBottle); (CocaCola, smallCup); (Tuborg, smallCup)|]
//the method can't store the updated array.
let mkOrder (dr:liquid ,cont:Containment) = Array.append source [|(dr, cont)|]
您好,我在这里有一种方法可以将新项目附加到源数组。但是,该方法不存储更新的数组,因此,只有在我尝试了多种不同的但都没有工作后才有效。
显然不是很惯用的 F#,但请随时说明您需要什么样的数据结构以及如何使用它:
open System.Collections.Generic
let source = ResizeArray<string * string >( [("CocaCola", "bigBottle"); ("CocaCola", "smallCup"); ("Tuborg", "smallCup")])
source.Add("Beer", "XL")
source
val it : ResizeArray = seq [("CocaCola", "bigBottle"); (“可口可乐”,“小杯”);("Tuborg", "smallCup"); (“啤酒”,“XL”)]
ResizeArray
是 C# 的别名,List
它是一个可变且可调整大小的数组。您可以添加、删除和执行大多数需要使用IEnumerable
.
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句