Method: Jekyll::J1_Filters#difference

Defined in:
lib/starter_web/_plugins/filter/filters.rb

#difference(input, arr) ⇒ Object


Managing Arrays
 input - arr:  returns any elements from input that are NOT in arr
 arr - input:  returns any elements from arr that are not in a
 arr | input:  returns the unique set from input AND arr
 arr & input:  returns the intersection elements of input AND arr
 pipe (|):     returns the unique set of elements for BOTH arrays

Example|s:

 {% assign input = '1,2,3,4,5' | split: ',' %}
 {% assign arr   = '1,2,3' | split: ',' %}

 {% assign difference    = input | difference: arr %}
 {% assign union         = input | union: arr %}
 {% assign intersection  = input | intersection: arr %}

NOTE
  See: https://stackoverflow.com/questions/5678108/how-can-i-get-the-intersection-union-and-subset-of-arrays-in-ruby



158
159
160
161
162
163
164
# File 'lib/starter_web/_plugins/filter/filters.rb', line 158

def difference(input, arr)
  if ( input.kind_of?(Array) )
    input - arr
  else
    []
  end
end