Skip to content

Instantly share code, notes, and snippets.

@jaredfolkins
Created July 5, 2011 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredfolkins/1065421 to your computer and use it in GitHub Desktop.
Save jaredfolkins/1065421 to your computer and use it in GitHub Desktop.
A few examples will help to clarify these operations. Let's begin by creating two arrays:
operating_systems = ["Fedora", "SuSE", "RHEL", "Windows", "MacOS"]
linux_systems = ["RHEL", "SuSE", "PCLinuxOS", "Ubuntu", "Fedora"]
Now, we can create a union of the two arrays:
operating_systems | linux_systems
=> ["Fedora", "SuSE", "RHEL", "Windows", "MacOS", "PCLinuxOS", "Ubuntu"]
As we can see from the above output, the union operation joined one array to another, but removed any duplicate array elements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment