hd-lang

Tour · 6 of 25

There is no null: a value that may be missing says so in its type

In a language with null, any value might be missing, and you find out when the program crashes. In hd, string? (short for Option[string]) is either .Some(text) or .None, and a plain string is always there. You can't call string methods on a string? until you decide what a missing value means: a fallback with unwrap_or, a match, or ? to pass the .None up. Returning a plain value where an optional is expected needs no wrapping, as return user.email shows.

Run: Ctrl+Enter · Pages: Alt+← Alt+→