Safe navigation operator

Alex Rønne Petersen xtzgzorex at
Sun Feb 19 18:15:25 PST 2012

On 20-02-2012 03:00, Andrej Mitrovic wrote:
> Hmm.. safe, but what about void methods? Silently not invoking methods
> seems like a bad idea to me.
> crypto?.encrypt(password)
> Oops! :P
> The Elvis operator looks kind of neat though. Although in D it's a bit
> challenging since cast(bool) doesn't always do what you want. E.g. it
> returns false on non-initialized string, true on zero-length
> initialized string.

I think the Elvis operator only makes sense on fields and properties.

Good point about cast(bool).

- Alex

More information about the Digitalmars-d mailing list