Danny Tuppeny
2017-02-12 16:58:26 UTC
I've had to put parents in this code ot make it compile but I don't really
understand why:
Serializers serializers =
(
_$serializers
.toBuilder()
..addPlugin(new StandardJsonPlugin())
).build();
As I understood it, the method cascade operator caused what was on its left
to be returned and the return value of the right side to be discarded.
Therefore, given this code:
Serializers serializers =
_$serializers
.toBuilder()
..addPlugin(new StandardJsonPlugin())
.build();
My expectation was that .build() would be called on the SerializersBuilder
that we called addPlugin on. However, It gives the error "The method
'build' isn't defined for class 'void'".
Have I misunderstood? It always worked as I expected before. Example 1 on Gilad's
post
<http://news.dartlang.org/2012/02/method-cascades-in-dart-posted-by-gilad.html>
actually shows the same, though it doesn't explain the parens :(
understand why:
Serializers serializers =
(
_$serializers
.toBuilder()
..addPlugin(new StandardJsonPlugin())
).build();
As I understood it, the method cascade operator caused what was on its left
to be returned and the return value of the right side to be discarded.
Therefore, given this code:
Serializers serializers =
_$serializers
.toBuilder()
..addPlugin(new StandardJsonPlugin())
.build();
My expectation was that .build() would be called on the SerializersBuilder
that we called addPlugin on. However, It gives the error "The method
'build' isn't defined for class 'void'".
Have I misunderstood? It always worked as I expected before. Example 1 on Gilad's
post
<http://news.dartlang.org/2012/02/method-cascades-in-dart-posted-by-gilad.html>
actually shows the same, though it doesn't explain the parens :(
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.