[ 
https://issues.apache.org/jira/browse/COLLECTIONS-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16064728#comment-16064728
 ] 

Sebb commented on COLLECTIONS-605:
----------------------------------

Whilst it is marginally shorter, IMO it's less obvious what is happening.

The only part of the original that is verbose is the for loop, and there are 
other ways to express that.

Without the shorthand method, the code would be:

{code}
row = new ArrayList<Object>(numColumns);
row.addAll(Collections.nCopies(numColumns, null));
{code}

Similar amount of code, and IMO no harder to follow than the proposed addition.

Sorry, but without a more compelling example, I personally don't think the new 
method is VFM (value for money, or in this case maintenance).


> Add new CollectionUtils Feature - addNCopies
> --------------------------------------------
>
>                 Key: COLLECTIONS-605
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-605
>             Project: Commons Collections
>          Issue Type: New Feature
>    Affects Versions: 4.1
>            Reporter: BELUGA BEHR
>            Priority: Trivial
>         Attachments: COLLECTIONS-605.1.patch
>
>
> Java's {{java.util.Collections}} has:
> {code}
> nCopies(int n, T o)
> Returns an immutable list consisting of n copies of the specified object.
> addAll(Collection<? super T> c, T... elements)
> Adds all of the specified elements to the specified collection.
> fill(List<? super T> list, T obj)
> Replaces all of the elements of the specified list with the specified element.
> {code}
> However, it does not have the ability to add nCopies directly to a Collection.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to