This is the old RCRchive. It's available only for reading and reference. To submit RCRs for Ruby 1.9/2.0, and to participate in discussions about them, please visit the new RCRchive.
ruby picture

RCR 351: More compatibility between Array and Set

Submitted by CyberGarp (Tue Oct 31 02:41:11 UTC 2006)

Abstract

A simple request, the add method in Set would be nice to have in Array.

Problem

I have some areas where Set and Array need to be used interchangeably for storage as unique or non-unique values. Having an add for both of these make the syntax of later usage the same via duck-typing.

Proposal

class Array will now have a method add, analogous to push.

Analysis

No impact on existing applications.

Implementation

class Array
  alias add push
end
ruby picture
Comments Current voting
Strongly opposed0
Opposed0
Neutral0
In favor0
Strongly advocate0
ruby picture
ruby picture

Powered by Ruby on Rails.