How does array assignment for different sized types work?

Jacob Carlborg doob at me.com
Wed Jan 30 23:18:01 PST 2013


On 2013-01-31 05:48, estew wrote:
> void main() {
>       float[3] v1 = [1.0, 2.0, 3.0];    // No error
>       float[3] v = [1.0, 2.0, 3.0].dup; // Fails at runtime with
> error message
> }
>
>
> Why does the array assignment work when "dup" is not used. My
> understanding is that arrays, like classes, are references.

There are dynamic arrays and static arrays. Dynamic arrays are reference 
types, static arrays are value types. You have declared a static array.

http://dlang.org/arrays.html

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list