ruby picture

RCR 326: Add Method 'length' to REXML::Elements

Submitted by zdennis (Wed Nov 16 13:01:41 UTC 2005)

Abstract

The REXML::Elements class acts like an array, yet it only responds to the method 'size'. Being able to call 'length' seems like an intuitive metohd for the class to have.

Problem

The REXML::Elements class acts like an array, yet it only responds to the method 'size'. Being able to call 'length' seems like an intuitive metohd for the class to have.

Proposal

Add the method 'length' as an alias to 'size' on the REXML::Elements class.

Analysis

This proposal keeps consistency with arrays and other array-like objects found in ruby's core libraries and standard libraries, and it seems to follow principle of least surprise.

Implementation

In rexml/element.rb on line 929 add the following line of code:

alias :length :size

ruby picture
Comments Current voting
RCR does not cover the libraries I (matz) don't maintain. I like this proposal though. Ask for the maintainer (mneumann).


Strongly opposed 0
Opposed 0
Neutral 0
In favor 1
Strongly advocate 0
ruby picture
If you have registered at RCRchive, you may now sign in below. If you have not registered, you may sign up for a username and password. Registering enables you to submit new RCRs, and vote and leave comments on existing RCRs.
Your username:
Your password:

ruby picture

Powered by .