takeFirstF takes the first value that returns true
(values []Value, take func(v Value) bool)
| 879 | |
| 880 | // takeFirstF takes the first value that returns true |
| 881 | func takeFirstF[Value any](values []Value, take func(v Value) bool) Value { |
| 882 | for _, v := range values { |
| 883 | if take(v) { |
| 884 | return v |
| 885 | } |
| 886 | } |
| 887 | // If all empty, return the last element |
| 888 | if len(values) > 0 { |
| 889 | return values[len(values)-1] |
| 890 | } |
| 891 | var empty Value |
| 892 | return empty |
| 893 | } |
| 894 | |
| 895 | // takeFirst will take the first non-empty value. |
| 896 | func takeFirst[Value comparable](values ...Value) Value { |