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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user