Motive behind !empty() with front() instead of Optional front()

Paul Backus snarwin at gmail.com
Wed Mar 24 23:13:59 UTC 2021


On Wednesday, 24 March 2021 at 21:09:52 UTC, IGotD- wrote:
> Another motive would be that it would force to check if the 
> return value is not empty, however you might not want that. For 
> example in a loop and you know the amount of elements in 
> advance then the check is unnecessary.

If you know the Optional isn't empty you can just call `.unwrap` 
(or whatever it ends up being called) to get the value without 
checking.


More information about the Digitalmars-d mailing list