Optional parameters?
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Sun Apr 1 22:25:45 UTC 2018
On Sunday, April 01, 2018 22:06:57 Boris-Barboris via Digitalmars-d-learn
wrote:
> On Sunday, 1 April 2018 at 15:54:16 UTC, Steven Schveighoffer
>
> wrote:
> > I currently have a situation where I want to have a function
> > that accepts a parameter optionally.
>
> I would simply use a pointer for this. Fighting D grammar seems
> too much of a hassle for such simple task.
How would a pointer help? Instead of doing
foo(nullable(42))
he'd have to do
foo(new int(42))
which is just one character shorter and ends up allocating on the heap,
unlike with Nullable.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list