5 ms·
V uses Result types for handling errors, and the developer must handle them by propagating the error or breaking/returning or panicing. For example: // os.v
by amedvednikov 3y ago
V uses Result types for handling errors, and the developer must handle them by propagating the error or breaking/returning or panicing.
For example:
// os.v
fn open(path string) !File {}
// main.v
file := os.open('out.txt') or { panic('failed to open: $err') }
file := os.open('out.txt') or { return }
file := os.open('out.txt')! // propagate the error
if file := os.open('out.txt') {} // alternative scoped syntax
- deleted 3y ago[deleted]
- fuzztester 3y agoThanks. V syntax looks somewhat clear.