Say, I have:
var buffer = StringBuffer();
buffer.toString(); // works (understandable)
buffer.write('foo').toString(); // fails because `write` returns `void` (understandable)
buffer..write('bar').toString(); // but why does it fail?
You can see buffer..write('bar')
returns a StringBuffer
instance, and I should be able to call toString()
on that instance. But why it doesn't work that way.
PS: I know I can use buffer..write('bar')..toString()
to make it work but my question is not how to make that work rather I want to know the reason why it didn't work.