Set null as function array parameter
Oleg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jan 12 08:32:30 PST 2015
On Monday, 12 January 2015 at 15:59:43 UTC, Adam D. Ruppe wrote:
> Why are you using ref? Take that off and you can pass any
> array, including null, with ease.
Because dynamic arrays are passed by value to functions. Will it
make another copy of array, if I'll pass array by value?
Looks like it won't (I've checked pointers), but I read in wiki
(http://en.wikibooks.org/wiki/D_%28The_Programming_Language%29/d2/Strings_and_Dynamic_Arrays#Passing_Dynamic_Arrays_to_Functions)
that it will copy "structure that contains the -pointer to the
first element- and the length is copied and passed". Does it mean
something else? maybe i don't understand it correctly.
More information about the Digitalmars-d-learn
mailing list