3 ms·
This is a place where local variable type inference really comes in handy for cutting down the noise of the type declarations. var descendingTransactionsByVa
by douche 10y ago
This is a place where local variable type inference really comes in handy for cutting down the noise of the type declarations.
var descendingTransactionsByValue = comparing(Transaction::getValue).reversed();
var groceries = transactions.filter(t -> t.getType() == Transaction.GROCERY);
var sortedGroceries = groceries.sorted(descendingTransactionsByValue);
var transactionids = sortedGroceries.map(Transaction::getId).collect(toList());
is much easier to understand
- rakpol 10y agoOh definitely, although I'll have to wait for it to be added to the JDK [1] in order to use that in anger :/ (outside of lombok) [1]: http://openjdk.java.net/jeps/286 http://openjdk.java.net/jeps/286