facets-0.7.2

B

Brian Buckley

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_permut=
ation.rb:26:in
`each_permutation'
C:/ruby/lib/ruby/gems/1.8/gems/facets-0.7.2/lib/facet/array/each_permut=
ation.rb:25:in
`each_with_index'
C:/ruby/lib/ruby/gems/1.8/gems/facets-0.7.2/lib/facet/array/each_permut=
ation.rb:25:in
`each'
C:/ruby/lib/ruby/gems/1.8/gems/facets-0.7.2/lib/facet/array/each_permut=
ation.rb:25:in
`each_with_index'
C:/ruby/lib/ruby/gems/1.8/gems/facets-0.7.2/lib/facet/array/each_permut=
ation.rb:25:in
`each_permutation'
C:/eclipse/workspace/actuarial_support/zsandbox/array_stuff.rb:35:in
`test_permutation'
 
T

Trans

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.
 
B

Brian Buckley

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top