Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Array#repeated_permutation should have arity 1 #1335

Merged
merged 1 commit into from

2 participants

@dmarcotte

Remove arg-less Array#repeated_permutation to match MRI behavior. (Noticed this implementing Array#repeated_permutation.size: it relies on #repeated_permutation having an arg)

$ ruby -e "p [].repeated_permutation"
-e:1:in `repeated_permutation': wrong number of arguments (0 for 1) (ArgumentError)
    from -e:1:in `<main>'

vs.

$ jruby -e "p [].repeated_permutation"
#<Enumerator: []:repeated_permutation>
@dmarcotte dmarcotte Array#repeated_permutation should have arity 1
Remove arg-less Array#repeated_permutation to match MRI behavior.
89a7ba2
@enebo enebo merged commit 8db840c into jruby:jruby-1_7
@enebo enebo modified the milestone: JRuby 1.7.10, JRuby 1.7.11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 12, 2013
  1. @dmarcotte

    Array#repeated_permutation should have arity 1

    dmarcotte authored
    Remove arg-less Array#repeated_permutation to match MRI behavior.
This page is out of date. Refresh to see the latest.
View
5 core/src/main/java/org/jruby/RubyArray.java
@@ -3708,11 +3708,6 @@ public IRubyObject repeated_permutation(ThreadContext context, IRubyObject num,
return block.isGiven() ? permutationCommon(context, RubyNumeric.num2int(num), true, block) : enumeratorize(context.runtime, this, "repeated_permutation", num);
}
- @JRubyMethod(name = "repeated_permutation", compat = RUBY1_9)
- public IRubyObject repeated_permutation(ThreadContext context, Block block) {
- return block.isGiven() ? permutationCommon(context, realLength, true, block) : enumeratorize(context.runtime, this, "repeated_permutation");
- }
-
private IRubyObject permutationCommon(ThreadContext context, int r, boolean repeat, Block block) {
if (r == 0) {
block.yield(context, newEmptyArray(context.runtime));
View
7 spec/regression/array_repeated_permutation_requires_arg_spec.rb
@@ -0,0 +1,7 @@
+require 'rspec'
+
+describe "Array#repeated_permutation" do
+ it "has arity one" do
+ [].method(:repeated_permutation).arity.should == 1
+ end
+end if RUBY_VERSION >= "1.9"
Something went wrong with that request. Please try again.