7 ms·
That example in article is straight up terrible. The Java version would be: var input = "Some kind of string."; var output = Optional.of(input) .map(
by 2WSSd-JzVM 10mo ago
That example in article is straight up terrible. The Java version would be:
var input = "Some kind of string.";
var output = Optional.of(input)
.map(i -> i.trim())
.map(i -> i.replace(' ', '-'))
.map(i -> i.replaceAll("[./…]", ""))
.map(i -> i.toLowerCase())
.get();
That is until you realize there is no reason to go weird with arrow operators when String is an object:
var input = "Some kind of string.";
var output = input.trim()
.replace(' ', '-')
.replaceAll("[./…]", "")
.toLowerCase();
It looks like they solved the wrong issue but that is probably just side effect of using trivial examples.