Skip to content

Instantly share code, notes, and snippets.

@phlipper
Created July 21, 2012 19:05
Show Gist options
  • Select an option

  • Save phlipper/3156845 to your computer and use it in GitHub Desktop.

Select an option

Save phlipper/3156845 to your computer and use it in GitHub Desktop.
Flatten multiple arrays at once using multiple splats with Ruby 1.9
first = [1, 2, 3]
# => [1, 2, 3]
middle = [4, 5, 6]
# => [4, 5, 6]
last = [7, 8, 9]
# => [7, 8, 9]
all = [*first, *middle, *last]
# => [1, 2, 3, 4, 5, 6, 7, 8, 9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment