Skip to content

Commit

Permalink
Implement Array#prepend and Array#append aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBr committed Jan 3, 2018
1 parent 7c77dbb commit 6ebd0ef
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -1264,14 +1264,14 @@ public RubyArray push_m(IRubyObject[] items) {
return push(items);
}

@JRubyMethod(name = "push", required = 1)
@JRubyMethod(name = "push", alias = "append", required = 1)
public RubyArray push(IRubyObject item) {
append(item);

return this;
}

@JRubyMethod(name = "push", rest = true)
@JRubyMethod(name = "push", alias = "append", rest = true)
public RubyArray push(IRubyObject[] items) {
if (items.length == 0) modifyCheck();
for (int i = 0; i < items.length; i++) {
Expand Down Expand Up @@ -1342,7 +1342,7 @@ public IRubyObject shift(ThreadContext context, IRubyObject num) {
return result;
}

@JRubyMethod(name = "unshift")
@JRubyMethod(name = "unshift", alias = "prepend")
public IRubyObject unshift() {
modifyCheck();
return this;
Expand All @@ -1356,7 +1356,7 @@ public IRubyObject unshift19() {
/** rb_ary_unshift
*
*/
@JRubyMethod(name = "unshift")
@JRubyMethod(name = "unshift", alias = "prepend")
public IRubyObject unshift(IRubyObject item) {
unpack();
modifyCheck();
Expand Down Expand Up @@ -1391,7 +1391,7 @@ public IRubyObject unshift19(IRubyObject item) {
return unshift(item);
}

@JRubyMethod(name = "unshift", rest = true)
@JRubyMethod(name = "unshift", alias = "prepend", rest = true)
public IRubyObject unshift(IRubyObject[] items) {
unpack();
modifyCheck();
Expand Down

0 comments on commit 6ebd0ef

Please sign in to comment.