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

Function takeFirstF

coderd/database/dbfake/dbfake.go:881–893  ·  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

879
880// takeFirstF takes the first value that returns true
881func 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.
896func takeFirst[Value comparable](values ...Value) Value {

Callers 1

takeFirstFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected