function parameters: is it possible to pass byref ... while being optional at the same time ?

Jack Applegame japplegame at gmail.com
Sat Jul 17 21:46:38 UTC 2021


On Saturday, 17 July 2021 at 20:49:58 UTC, someone wrote:
> The following gives me a compiler error when I add the second 
> parameter:
> is not an lvalue and cannot be modified
>
> ```d
> public bool add(
>    ref classTickerID robjTickerID,
>    ref classExchanges robjExchanges = null /// needing this 
> optional
>    ) {
>
> }
> ```
>
> If I take out the null then the parameter is assumed mandatory 
> of course.

Just remove `ref`, because in D clasess themselves are references.


More information about the Digitalmars-d-learn mailing list