Returning dynamic array from the function?
SuperPrower
superprower at somedomain.org
Sat Sep 8 10:22:38 UTC 2018
On Saturday, 8 September 2018 at 10:05:31 UTC, rikki cattermole
wrote:
> onReceive:
> "The event handler that receives incoming data. Be sure to copy
> the incoming ubyte[] since it is not guaranteed to be valid
> after the callback returns."
>
> It could be a buffer on the stack, either way, .dup it before
> you cast.
Yeah, it worked, thank you. I knew it was something trivial like
that. It appears I slightly misunderstood by this paragraph
https://dlang.org/spec/arrays.html#array-copying - I missed that
slice operator is supposed to be on the left-side rather than
right (I thought adding `[]` to the `data` would do the trick).
Also, is this me and my bad English, or first comment in code in
this paragraph (linked above, not in the discussion) is supposed
to be something different? Shouldn't it be reference?
More information about the Digitalmars-d-learn
mailing list