Skip to content

Commit

Permalink
coalesce
Browse files Browse the repository at this point in the history
  • Loading branch information
mniak committed Sep 3, 2021
1 parent 1ca5043 commit 4a0a987
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"strconv"
)

func coalesce(value, fallback string) string {
if value == "" {
return fallback
func coalesce(value string, fallback ...string) string {
if value == "" && len(fallback) > 0 {
coalesce(fallback[0], fallback[1:]...)
}
return value
}
Expand Down

0 comments on commit 4a0a987

Please sign in to comment.