mirror of
https://github.com/vlang/v.git
synced 2025-09-10 07:47:20 -04:00
doc: fix misleading description of optionals
This commit is contained in:
parent
7f5e3b36bc
commit
d5eafe79bd
@ -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
|
`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
|
Basically the code above is a shorter version of
|
||||||
|
|
||||||
```v
|
```v
|
||||||
resp := http.get(url) or {
|
resp := http.get(url) or {
|
||||||
panic(err)
|
return error(err)
|
||||||
}
|
}
|
||||||
println(resp.body)
|
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()`
|
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.
|
or Swift's `!`). You have to use `or { panic(err) }` instead.
|
||||||
|
|
||||||
|
|
||||||
## Generics
|
## Generics
|
||||||
|
|
||||||
```v
|
```v
|
||||||
|
Loading…
x
Reference in New Issue
Block a user