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

Nick Treleaven nick at geany.org
Fri Mar 26 17:47:37 UTC 2021


On Friday, 26 March 2021 at 15:51:41 UTC, Per Nordlöw wrote:
> Can you elaborate on what you mean by "compile-time checked 
> optional types"?

Like `if let` in Swift:
https://www.hackingwithswift.com/sixty/10/2/unwrapping-optionals

This form ensures at compile time that a runtime check has made 
in code that accesses the value held by the optional.

(There's also a `guard let` form to unwrap into a variable in the 
current scope that requires you to terminate the current scope 
when the optional is empty).



More information about the Digitalmars-d mailing list