@@ -54,6 +54,14 @@ public Chain<List<T>> drop() {
5454 public Chain <List <T >> drop (final Integer n ) {
5555 return new Chain <List <T >>($ .drop (value (), n ));
5656 }
57+
58+ public Chain <List <T >> dropRight () {
59+ return new Chain <List <T >>($ .dropRight (value ()));
60+ }
61+
62+ public Chain <List <T >> dropRight (final Integer n ) {
63+ return new Chain <List <T >>($ .dropRight (value (), n ));
64+ }
5765 }
5866
5967 public static Chain chain (final String item ) {
@@ -72,12 +80,12 @@ public static <T> Chain chain(final T ... list) {
7280 return new $ .Chain <T >(Arrays .asList (list ));
7381 }
7482
75- public static <T > List <List <T >> chunk (final Iterable <T > list , final Integer size ) {
83+ public static <T > List <List <T >> chunk (final Iterable <T > iterable , final Integer size ) {
7684 int index = 0 ;
77- int length = size (list );
85+ int length = size (iterable );
7886 final List <List <T >> result = new ArrayList <List <T >>(length / size );
7987 while (index < length ) {
80- result .add (newArrayList (list ).subList (index , Math .min (length , index + size )));
88+ result .add (newArrayList (iterable ).subList (index , Math .min (length , index + size )));
8189 index += size ;
8290 }
8391 return result ;
@@ -87,22 +95,38 @@ public List<List<T>> chunk(final Integer size) {
8795 return chunk (getIterable (), size );
8896 }
8997
90- public static <T > List <T > drop (final Iterable <T > list ) {
91- return rest (newArrayList (list ));
98+ public static <T > List <T > drop (final Iterable <T > iterable ) {
99+ return rest (newArrayList (iterable ));
92100 }
93101
94102 public List <T > drop () {
95103 return drop (getIterable ());
96104 }
97105
98- public static <T > List <T > drop (final Iterable <T > list , final Integer n ) {
99- return rest (newArrayList (list ), n );
106+ public static <T > List <T > drop (final Iterable <T > iterable , final Integer n ) {
107+ return rest (newArrayList (iterable ), n );
100108 }
101109
102110 public List <T > drop (final Integer n ) {
103111 return drop (getIterable (), n );
104112 }
105113
114+ public static <T > List <T > dropRight (final Iterable <T > iterable ) {
115+ return initial (newArrayList (iterable ));
116+ }
117+
118+ public List <T > dropRight () {
119+ return dropRight (getIterable ());
120+ }
121+
122+ public static <T > List <T > dropRight (final Iterable <T > iterable , final Integer n ) {
123+ return initial (newArrayList (iterable ), n );
124+ }
125+
126+ public List <T > dropRight (final Integer n ) {
127+ return dropRight (getIterable (), n );
128+ }
129+
106130 public static void main (String ... args ) {
107131 final String message = "Underscore-java-lodash is a lodash plugin for underscore-java.\n \n "
108132 + "For docs, license, tests, and downloads, see: http://javadev.github.io/underscore-java" ;
0 commit comments