MCPcopy Index your code
hub / github.com/coder/coder / takeFirstF

Function takeFirstF

coderd/database/dbgen/dbgen.go:2134–2146  ·  view source on GitHub ↗

takeFirstF takes the first value that returns true

(values []Value, take func(v Value) bool)

Source from the content-addressed store, hash-verified

2132
2133// takeFirstF takes the first value that returns true
2134func 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.
2149func takeFirst[Value comparable](values ...Value) Value {

Callers 4

takeFirstIPFunction · 0.70
takeFirstSliceFunction · 0.70
takeFirstMapFunction · 0.70
takeFirstFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected