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:
parent
dbaa91810f
commit
1e2a92945c
@ -353,13 +353,21 @@ fn parse_header0(s string) ?string {
|
|||||||
return error('missing colon in header')
|
return error('missing colon in header')
|
||||||
}
|
}
|
||||||
words := s.split_nth(':', 2)
|
words := s.split_nth(':', 2)
|
||||||
// x := words[0]
|
x := words[0]
|
||||||
// return x
|
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]
|
return words[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn advanced_optionals() {
|
fn advanced_optionals() {
|
||||||
s := parse_header0('foo:bar') or { return }
|
s := parse_header0('foo:bar') or { return }
|
||||||
|
s2 := parse_header1('foo:bar') or { return }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user