From d5eafe79bd2c0f8db2a45c35632dfe32aed5232a Mon Sep 17 00:00:00 2001 From: dumblob Date: Thu, 23 Apr 2020 05:35:33 +0200 Subject: [PATCH] doc: fix misleading description of optionals --- doc/docs.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index 21dac48ad0..29e4c7cc21 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -1000,12 +1000,12 @@ println(resp.body) ``` `http.get` returns `?http.Response`. It was called with `?`, so the error is propagated to the calling function -(which must return an optional) or in case of `main` leads to a panic. +(which must return an optional) or in case of `main()` leads to a panic. Basically the code above is a shorter version of ```v resp := http.get(url) or { - panic(err) + return error(err) } println(resp.body) ``` @@ -1013,6 +1013,7 @@ println(resp.body) V does not have a way to force unwrap an optional (like Rust's `unwrap()` or Swift's `!`). You have to use `or { panic(err) }` instead. + ## Generics ```v