Skip to content

Commit

Permalink
Update vlib/os/os.v
Browse files Browse the repository at this point in the history
match looks more like idiomatic v than if-else-if-...-else

Co-authored-by: Turiiya <34311583+ttytm@users.noreply.github.com>
  • Loading branch information
hholst80 and ttytm committed May 4, 2024
1 parent 91520e4 commit e815e4e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions vlib/os/os.v
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,11 @@ pub fn join_path(base string, dirs ...string) string {
pub fn join_path_single(base string, elem string) string {
// TODO: deprecate this and make it `return os.join_path(base, elem)`,
// when freeing variadic args vs ...arr is solved in the compiler
if base != '' && elem != '' {
return '${base}${path_separator}${elem}'
} else if base != '' {
return base
} else if elem != '' {
return elem
} else {
return ''
return match true {
base != '' && elem != '' { '${base}${path_separator}${elem}' }
base != '' { base }
elem != '' { elem }
else { '' }
}
}

Expand Down

0 comments on commit e815e4e

Please sign in to comment.