Randy
Randy

Reputation: 1367

Understanding dart syntax

Coming from the java world I have difficulties to understand this code-fragment from the AngularDart pirate badge code lab:

    Future _loadData() {
        return _http.get('piratenames.json').then((HttpResponse response) {
          PirateName.names = response.data['names'];
          PirateName.appellations = response.data['appellations'];
        });
      }
    }

From my understanding PirateName is a class and how can the line

    PirateName.names = response.data['names'];

write a field of a class without referring to an actual instance?

Upvotes: 1

Views: 90

Answers (1)

Mihai Stancu
Mihai Stancu

Reputation: 16107

Dart syntax allows static variables as does Java.

That is a static variable as defined in the source you provided Edit piratebadge.dart and you'll see where it is defined as static.

Upvotes: 4

Related Questions