Am 28.03.2014 11:05, schrieb Florian Weimer:
    String mySub = myVeryLongNamedString.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.

Hm, nice hacks, but don't you notice the difference in readability and total amount of code lines in comparison to my proposed one-liner? IMHO the more lines/characters a code has, the more effort is needed to (1) read it and (2) understand it's sense.

BTW, our 2nd example wouldn't work as expression in for loop arguments.

But what for do we discuss the "leading dot expressions" such exhaustive, if there still is no conviction to add the simple "chaining syntax" to the Java language at all?

-Ulf

Reply via email to