Returns a new list with n
elements removed from the left.
Use List.sublist()
to remove the specified number of elements from the left.
代码实现
List<T> drop<T>(List<T> lst, [int n = 1]) {
return lst.sublist(n);
}
使用样例
drop([1, 2, 3]); // [2,3]
drop([1, 2, 3], 2); // [3]