Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save chadmiko/9c56b7db1acecd78f7f41a10ca58e092 to your computer and use it in GitHub Desktop.

Select an option

Save chadmiko/9c56b7db1acecd78f7f41a10ca58e092 to your computer and use it in GitHub Desktop.

Revisions

  1. @awesome awesome revised this gist Jan 22, 2010. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions opposite_of_array_intersection.rb
    Original file line number Diff line number Diff line change
    @@ -6,3 +6,9 @@ def awesome(ar_1, ar_2)
    end

    awesome([1,2,3,4], [3,4,5,6]) # => [1, 2, 5, 6]


    # bonus code from @texel
    # http://twitter.com/texel/status/8035307156

    (a - (a & b)) | (b - (a & b)) # => nice one!
  2. @awesome awesome created this gist Jan 21, 2010.
    8 changes: 8 additions & 0 deletions opposite_of_array_intersection.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    # Ruby opposite of array intersection... or maybe the method is missing from my brain bc not enough coffee
    # http://twitter.com/soawesomeman/status/8035087261

    def awesome(ar_1, ar_2)
    (ar_1 + ar_2) - (ar_1 & ar_2)
    end

    awesome([1,2,3,4], [3,4,5,6]) # => [1, 2, 5, 6]