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

autofree: test return x[0] (optional)

This commit is contained in:
Alexander Medvednikov 2021-04-06 17:28:07 +03:00
parent dbaa91810f
commit 1e2a92945c

View File

@ -353,13 +353,21 @@ fn parse_header0(s string) ?string {
return error('missing colon in header')
}
words := s.split_nth(':', 2)
// x := words[0]
// return x
x := words[0]
return x
}
fn parse_header1(s string) ?string {
if !s.contains(':') {
return error('missing colon in header')
}
words := s.split_nth(':', 2)
return words[0]
}
fn advanced_optionals() {
s := parse_header0('foo:bar') or { return }
s2 := parse_header1('foo:bar') or { return }
}
fn main() {