Facets-0.7.2

Hello,

When running the following code

require 'facet/array/each_permutation'
[1,2,3].each_permutation{|x| p x}

I get an undefined method error for `permute' (error trace below)

How does one add in the 'permute' method?

Brian

···

--------------------------------------------

NoMethodError: undefined method `permute' for [2, 3]:Array
    C:/ruby/lib/ruby/gems/1.8/gems/facets-0.7.2/lib/facet/array/each_permutation.rb:26:in
`each_permutation'
    C:/ruby/lib/ruby/gems/1.8/gems/facets-0.7.2/lib/facet/array/each_permutation.rb:25:in
`each_with_index'
    C:/ruby/lib/ruby/gems/1.8/gems/facets-0.7.2/lib/facet/array/each_permutation.rb:25:in
`each'
    C:/ruby/lib/ruby/gems/1.8/gems/facets-0.7.2/lib/facet/array/each_permutation.rb:25:in
`each_with_index'
    C:/ruby/lib/ruby/gems/1.8/gems/facets-0.7.2/lib/facet/array/each_permutation.rb:25:in
`each_permutation'
    C:/eclipse/workspace/actuarial_support/zsandbox/array_stuff.rb:35:in
`test_permutation'

Actually the #permute method was renamed to, surprise,
#each_permutation. It's a recursive method. So, just change #permute to
#each_permutation and it ought to work.

A new version will be out early next week (finally!) that also has this
fix.

Thanks,
T.

Actually the #permute method was renamed to, surprise,
#each_permutation. It's a recursive method. So, just change #permute to
#each_permutation and it ought to work.

A new version will be out early next week (finally!) that also has this
fix.

Thanks, T. In my code I added a temporary alias_method line after the
require line and now it works.

require 'facet/array/each_permutation'
#needed until facets-0.7.2 bug is fixed
class Array; alias_method :permute, :each_permutation end
[1,2,3].each_permutation{|x| p x} #now it works!