Implicit 'this' return for void methods
Florian Weimer
fweimer at redhat.com
Fri Mar 28 10:05:59 UTC 2014
On 03/28/2014 05:57 AM, Victor Polischuk wrote:
> Ulf,
>
> I think that point leading style is something which can be easily mistreat. If we complicate the example:
>
> String mySub = myVeryLongNamedString.substring(.indexOf("C"),.indexOf("Q"));
>
> to something like:
>
> String mySub = myVeryLongNamedString.concat("BLAH").substring(.indexOf("C"),.indexOf("Q"));
You can already write
String mySub = apply(myVeryLongNamedString,
(s) -> s.substring(s.indexOf("C"), s.indexOf("Q")))
with a helper function like this:
public static <T, R> R apply(T value, Function<T, R> func) {
return func.apply(value);
}
You don't even need to repeat the type. But the explicit version isn't
too bad, either:
String mySub;
{
String s = myVeryLongNamedString;
mySub = s.substring(s.indexOf("C"), s.indexOf("Q"));
}
So I'm not sure if leading dot expressions are all that helpful.
--
Florian Weimer / Red Hat Product Security Team
More information about the core-libs-dev
mailing list