If I have an array in Ruby, like this:
["foo", "bar", "bat"]
How can I generate a new array with every combination of values?
I need the output to look like this:
["foo", "bar", "bat", "foo-bar", "foo-bat", "bar-bat", "foo-bar-bat"]
Order is unimportant. Also, I do not need both "foo-bar"
and "bar-foo"
.
The original array may have up to 5-6 members.