takeFirstF takes the first value that returns true
(values []Value, take func(v Value) bool)
| 2132 | |
| 2133 | // takeFirstF takes the first value that returns true |
| 2134 | func takeFirstF[Value any](values []Value, take func(v Value) bool) Value { |
| 2135 | for _, v := range values { |
| 2136 | if take(v) { |
| 2137 | return v |
| 2138 | } |
| 2139 | } |
| 2140 | // If all empty, return the last element |
| 2141 | if len(values) > 0 { |
| 2142 | return values[len(values)-1] |
| 2143 | } |
| 2144 | var empty Value |
| 2145 | return empty |
| 2146 | } |
| 2147 | |
| 2148 | // takeFirst will take the first non-empty value. |
| 2149 | func takeFirst[Value comparable](values ...Value) Value { |
no outgoing calls
no test coverage detected