MCPcopy
hub / github.com/google/go-jsonnet / joinArrays

Function joinArrays

builtins.go:361–384  ·  view source on GitHub ↗
(i *interpreter, sep *valueArray, arr *valueArray)

Source from the content-addressed store, hash-verified

359}
360
361func joinArrays(i *interpreter, sep *valueArray, arr *valueArray) (value, error) {
362 result := make([]*cachedThunk, 0, arr.length())
363 first := true
364 for _, elem := range arr.elements {
365 elemValue, err := i.evaluatePV(elem)
366 if err != nil {
367 return nil, err
368 }
369 switch v := elemValue.(type) {
370 case *valueNull:
371 continue
372 case *valueArray:
373 if !first {
374 result = append(result, sep.elements...)
375 }
376 result = append(result, v.elements...)
377 default:
378 return nil, i.typeErrorSpecific(elemValue, &valueArray{})
379 }
380 first = false
381
382 }
383 return makeValueArray(result), nil
384}
385
386func joinStrings(i *interpreter, sep valueString, arr *valueArray) (value, error) {
387 result := make([]rune, 0, arr.length())

Callers 1

builtinJoinFunction · 0.85

Calls 4

makeValueArrayFunction · 0.85
evaluatePVMethod · 0.80
typeErrorSpecificMethod · 0.80
lengthMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…