Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/cricinfo.rb
Overview
array monkey patch snippets.dzone.com/posts/show/3332
Instance Method Summary collapse
Instance Method Details
#permutations ⇒ Object
17 18 19 20 21 22 |
# File 'lib/cricinfo.rb', line 17 def permutations return [self] if size < 2 perm = [] each { |e| (self - [e]).permutations.each { |p| perm << ([e] + p) } } perm end |