Add slices to slices

I am having a blank on how to add slices to an existing slice-, ehm, -collection (what’s the term?). It’s probably just me not knowing the tech-lingo of what I am trying to achieve, so here is a sasmple:

{{ $collection := slice "foo" "bar" "buzz" }}
{{ $collection2 := slice "bla" "fasel" }}

{{ $something := merge?? $collection $collection2 }}
// result: "foo" "bar" "buzz" "bla" "fasel"
{{ $collection.add?? (slice "ehm" "yeah") }}
// result: "foo" "bar" "buzz" "ehm" "yeah"

I know how to do it with a scratch, but that feels hacky to me or is it the only way?

{{ .Scratch.Add "greetings" (slice "Hello") }}
{{ .Scratch.Add "greetings" (slice "Welcome" "Cheers") }}
// result: "Hello" "Welcome" "Cheers"

Ah. I found append :wink:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.