在Julia中,如何创建唯一的,空的可变对象数组?

NHD*_*aly 3 arrays julia

的帮助字符串fill说:

help?> fill
search: fill fill! finally findall filter filter! filesize filemode FileSyntax FileSchema isfile CSVFile @__FILE__ CSVFileSyntax fieldtype fieldname

  fill(x, dims)

  Create an array filled with the value x. For example, fill(1.0, (5,5)) returns a 5×5 array of floats, with each element initialized to 1.0.

...

  If x is an object reference, all elements will refer to the same object. fill(Foo(), dims) will return an array filled with the result of evaluating
  Foo() once.
Run Code Online (Sandbox Code Playgroud)

注意最后一段:

如果x是对象引用,则所有元素都将引用同一对象。fill(Foo(), dims)将返回一个填充有Foo()一次评估结果的数组。

所以我想知道,怎么一个构建的Array n唯一对象?

例如说我想要3个空的,分开的字典的数组。


相关:在Julia中创建数组的数组

NHD*_*aly 5

我能想到的最好的方法是使用一种理解:

julia> ds = [Dict() for _ in 1:3]
2-element Array{Dict{Any,Any},1}:
 Dict()
 Dict()
 Dict()
Run Code Online (Sandbox Code Playgroud)

这是最好的方法吗?谢谢!