Re:Practical Go: Real-world advice for writing maintainable ...
by Sholmesy on Thursday February 21, 2019 @02:56PM
(#19220020)
// `http.get()` returns an optional string.
// V optionals combine the features of Rust's Option<T> and Result<T>.
// We must unwrap all optionals with `or`, otherwise V will complain.
s := http.get(API_URL) or {
// `err` is a reserved variable (not a global) that
// contains an error message if there is one
eprintln('Failed to fetch "users.json": $err')
// `or` blocks must end with `return`, `break`, or `continue`
return
}
This looks really handy. Is there somewhere else (outside of V) where I can read about Option types (in the real world, or in theory).
Re:Practical Go: Real-world advice for writing maintainable ...
by int_19h on Thursday February 21, 2019 @11:17PM
(#19223080)
What's the difference between "break" and "continue" inside an or-block? Or do they apply to the outer enclosing loop if there is one?
Re:Practical Go: Real-world advice for writing maintainable ...
by amedvednikov on Friday February 22, 2019 @07:14AM
(#19224667)
Yes, just like in Swift.
They are very simple and combine Rust's Option<T> and Result<T>.