Union.md - hugo - [fork] hugo port for 9front
 (HTM) git clone https://git.drkhsh.at/hugo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
       Union.md (1294B)
       ---
            1 ---
            2 title: collections.Union
            3 description: Given two arrays or slices, returns a new array that contains the elements that belong to either or both arrays/slices.
            4 categories: []
            5 keywords: []
            6 params:
            7   functions_and_methods:
            8     aliases: [union]
            9     returnType: any
           10     signatures: [collections.Union SET1 SET2]
           11 aliases: [/functions/union] 
           12 ---
           13 
           14 Given two arrays (or slices) A and B, this function will return a new array that contains the elements or objects that belong to either A or to B or to both.
           15 
           16 ```go-html-template
           17 {{ union (slice 1 2 3) (slice 3 4 5) }} → [1 2 3 4 5]
           18 
           19 {{ union (slice 1 2 3) nil }} → [1 2 3]
           20 
           21 {{ union nil (slice 1 2 3) }} → [1 2 3]
           22 
           23 {{ union nil nil }} → []
           24 ```
           25 
           26 ## OR filter in where query
           27 
           28 This is also very useful to use as `OR` filters when combined with where:
           29 
           30 ```go-html-template
           31 {{ $pages := where .Site.RegularPages "Type" "not in" (slice "page" "about") }}
           32 {{ $pages = $pages | union (where .Site.RegularPages "Params.pinned" true) }}
           33 {{ $pages = $pages | intersect (where .Site.RegularPages "Params.images" "!=" nil) }}
           34 ```
           35 
           36 The above fetches regular pages not of `page` or `about` type unless they are pinned. And finally, we exclude all pages with no `images` set in Page parameters.
           37 
           38 See [intersect](/functions/collections/intersect) for `AND`.