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

checker: fmt

This commit is contained in:
Alexander Medvednikov
2020-05-11 14:38:25 +02:00
parent 8a6820d1b7
commit 828f9af64c
2 changed files with 41 additions and 33 deletions

View File

@ -9,7 +9,7 @@ mut:
fn main() {
s := '[{ "name":"Frodo", "age":25}, {"name":"Bobby", "age":10}]'
users := json.decode([]User, s) or {
mut users := json.decode([]User, s) or {
eprintln('Failed to parse json')
return
}
@ -20,10 +20,10 @@ fn main() {
for i, user in users {
println('$i) $user.name')
if !user.can_register() {
println('Cannot register $user.name, he is too young')
} else {
users[i].register()
println('$user.name is registered')
println('Cannot register $user.name, they are too young')
} else {
users[i].register()
println('$user.name is registered')
}
}
// Let's encode users again just for fun