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

urllib: change Values.get to return an option type (#17636)

This commit is contained in:
Heptalon
2023-03-14 07:44:40 +01:00
committed by GitHub
parent daa9034583
commit 618c92a13b
3 changed files with 11 additions and 9 deletions

View File

@@ -27,17 +27,17 @@ pub fn new_values() Values {
// get gets the first value associated with the given key.
// If there are no values associated with the key, get returns
// a empty string.
pub fn (v &Values) get(key string) string {
// none.
pub fn (v &Values) get(key string) ?string {
if v.data.len == 0 {
return ''
return none
}
for qvalue in v.data {
if qvalue.key == key {
return qvalue.value
}
}
return ''
return none
}
// get_all gets the all the values associated with the given key.