1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

doc: minor fixes in examples (#15125)

This commit is contained in:
Fossean1 2022-07-19 22:59:59 +05:00 committed by GitHub
parent a13b8ff0c8
commit 1ccb4c3ac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2091,12 +2091,13 @@ Public immutable fields are readonly everywhere.
V supports anonymous structs: structs that don't have to be declared separately V supports anonymous structs: structs that don't have to be declared separately
with a struct name. with a struct name.
``` ```v
struct Book { struct Book {
author struct { author struct {
name string name string
age int age int
} }
title string title string
} }
@ -3415,7 +3416,7 @@ import net.http
fn f(url string) ?string { fn f(url string) ?string {
resp := http.get(url)? resp := http.get(url)?
return resp.text return resp.body
} }
``` ```
@ -3430,7 +3431,7 @@ The body of `f` is essentially a condensed version of:
```v ignore ```v ignore
resp := http.get(url) or { return err } resp := http.get(url) or { return err }
return resp.text return resp.body
``` ```
--- ---
@ -3474,7 +3475,7 @@ The fourth method is to use `if` unwrapping:
import net.http import net.http
if resp := http.get('https://google.com') { if resp := http.get('https://google.com') {
println(resp.text) // resp is a http.Response, not an optional println(resp.body) // resp is a http.Response, not an optional
} else { } else {
println(err) println(err)
} }