3 ms·
I know this is supposed to show us about cool java 8 features, but what it's actually reminding me is how jarring BigDecimal is without operator overloading.
by yarper 11y ago
I know this is supposed to show us about cool java 8 features, but what it's actually reminding me is how jarring BigDecimal is without operator overloading.
- ajanuary 11y agoHaving a method allows sum to be written as: return listOfTxnAmounts.stream().reduce(BigDecimal.ZERO, BigDecimal::add); rather than what you have to do for operators(unless there is a way of referencing the operators I haven't found): return listOfTxnAmounts.stream().reduce(0, (a, b) -> a + b);
- yarper 11y agoSure, the other way is this; Arrays.stream(new int[] { 1,2,3 }).sum();