Your IP : 3.22.27.41
--- !ruby/object:RI::MethodDescription
aliases: []
block_params:
comment:
- !ruby/struct:SM::Flow::P
body: When invoked with a block, yield all permutations of length <em>n</em> of the elements of <em>ary</em>, then return the array itself. If <em>n</em> is not specified, yield all permutations of all elements. The implementation makes no guarantees about the order in which the permutations are yielded.
- !ruby/struct:SM::Flow::P
body: When invoked without a block, return an enumerator object instead.
- !ruby/struct:SM::Flow::P
body: "Examples:"
- !ruby/struct:SM::Flow::VERB
body: " a = [1, 2, 3]\n a.permutation.to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]\n a.permutation(1).to_a #=> [[1],[2],[3]]\n a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]\n a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]\n a.permutation(0).to_a #=> [[]] # one permutation of length 0\n a.permutation(4).to_a #=> [] # no permutations of length 4\n"
full_name: Array#permutation
is_singleton: false
name: permutation
params: |
ary.permutation { |p| block } -> array
ary.permutation -> enumerator
ary.permutation(n) { |p| block } -> array
ary.permutation(n) -> enumerator
visibility: public