On Sep 5, 5:42 pm, Tegiri Nenashi <TegiriNena...@gmail.com> wrote:
... assignment is not an expression.
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);
this need would have arisen in the context of loop. From that