Chapter 9 - Advanced Classes - Calling super last in an initializer list

In Chapter 9 - Advaned Classes, in the section Calling super last in an initializer list, the example given is:

class SomeChild extends SomeParent {

  SomeChild(double height)
      : assert(height != 0),  // assert
        _height = height,     // initializer
        super();              // super

  final double _height;
}

Bu then the note below it basically states that the super() in the example is not actually needed because Dart will call it anyway if it is empty.

It feels like the example would be better if super was actually populated, as in the Student extends Person example, and then adding in a note that if there’s nothing in super, it’s not actually needed.

But, that might just be me, who is currently struggling with some of these concepts.

Thanks for the comment. I’m planning on doing a book update in January/February. I opened an issue in the book repo with a link to your comment. I’ll see if I can improve the example and/or explanation to make it more clear for readers.

Wonderful. Thank you.

It’s weird how some things just click, and others are a struggle.

Even though I have some programming background, and have been poking at Flutter for a bit, I just couldn’t understand everything that was happening, which is why I am working through DA now.

Things are starting to fall in to place, but I do still find myself looking at some of the examples going, “But where? But what? But why?” in various combinations.

I know for the print version space is an issue, so that can be a challenge, and why some of the examples are severely abbreviated, trying to build on the previous iteration presented, but that can present a challenge sometimes.

I’ve seen some tutorials where the entire block is laid out with line numbers and then chunks are examined with the line numbers helping to refer back to the original block. But I suspect that would be terribly expensive for the print version.

Do you have some specific examples of your “But where? But what? But why?”? That would help me understand better.

Generally we try to keep code blocks short, but if having a longer code block would improve readability, that is something we could consider. It’s not really an issue of printing cost.

I’ve finished rewording this example (following the advice in the post). It will be available in Dart Apprentice Beyond the Basics Chapter 3.

Brilliant! I’ll keep an eye out. Thanks for the followup!