Last active
August 29, 2015 14:27
-
-
Save rmw/547bcc5d64a1cccc9028 to your computer and use it in GitHub Desktop.
Get all combos of strings in 2 arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first_names = %w(rebecca jessica mabel) | |
middle_names = %w(jean lynn orla amelia) | |
[].tap do |names| | |
first_names.each do |first_name| | |
middle_names.each do |middle_name| | |
names << "#{first_name} #{middle_name}" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first_names = %w(rebecca jessica mabel) | |
middle_names = %w(jean lynn orla amelia) | |
first_names.product(middle_names).map do |name_product| | |
name_product.join(" ") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment