It's useful as a form of currying. And it's purely up to a language
designer or a library designer's choice. And it's purely subjective and
depends on individual's taste.
For example, even method calls can be curried.
Suppose you have a File object, which has a "write(String)" method. Now,
the library designer could have implemented it without currying:
void write(String x) { for(char c: x) this.writeChar(c); }
Then to write 3 strings, you would write:
file.write("A");
file.write("B");
file.write("C");
Or the library designer could have implemented it with currying (an
example of this is the StringBuilder class in Java standard library)
File write(String x) { for(char c: x) this.writeChar(c); return
this; }
Then to write 3 strings you can write:
file.write("A").write("B").write("C);
Okay, firstly, this example has nothing at all to do with assignment being
an expression. But never mind.
Secondly, may i ask where you learned to call this 'currying'? I'm aware
of the term, but its established meaning in computer science is something
rather different. Admittedly, something that if you look at it from a
distance, in the right light, looks strangely related, but different
nonetheless. I've heard the style you're describing referred to as
'chaining', or 'invocation chaining' before, but never 'currying'.
Personally, i'm not a big fan of it. In fact, i really, really dislike it
- it means abusing a method's return value to return something that isn't
in any sense a result of the method's execution. This is purely an
aesthetic concern, and a matter of taste, though.
I will mention that Smalltalk has something called method cascading.
Smalltalk statements are normally terminated by a full stop, but if you
use a semicolon, then you can omit a receiver from the next statement, and
it will use the receiver of the previous one. Which is clear as mud, so
here's an example:
file write: 'A'.
file write: 'B'.
file write: 'C'.
Becomes:
file write: 'A';
write: 'B';
write: 'C'.
Or, all on one line:
file write: 'A'; write: 'B'; write: 'C'.
It's a terribly simple bit of syntactic sugar which gives you all the
benefits of chaining without having to (a) design your classes to support
it or (b) pervert your design, depending on how you look at it. It's
particularly useful in Smalltalk, where the style is to write lots of
little methods, rather than a few big ones.
It's another thing that would (arguably) be nice to have in java, although
i don't know what punctuation we've got left for it! Comma, perhaps?
file.write("A"), write("B"), write("C") ;
Or perhaps indicate it by just omitting the receiver:
file.write("A"); .write("B"); .write("C") ;
tom