0

http://radar.oreilly.com/2013/05/dart-is-not-the-language-you-think-it-is.html

at the risk of asking a stupid question:

I have never seen this syntax before:

// Dart
class Point {
  num x, y;
  Point(this.x, this.y);

  String toString() => 'X: $x, Y: $y';
}

is &gt indicating a reference?

import 'dart:mirrors';

class LoggingProxy {
  InstanceMirror mirror;
  LoggingProxy(delegate)
    : mirror = reflect(delegate);

  noSuchMethod(Invocation invocation) {
    var name = invocation.memberName;
    print('${name} was called');
    return mirror.delegate(invocation);
  }
}

and what is the colon in:

LoggingProxy(delegate)
  : mirror = reflect(delegate);

doing?

chrisgotter
  • 383
  • 1
  • 3
  • 13

1 Answers1

1

The source code has been escaped for some reason:

String toString() => 'X: $x, Y: $y';

What do entities: < and > stand for?

It's simply => syntax shorthand for the function body that is equal to {return 'X: $x, Y: $y'; }
Should be String toString() => 'X: $x, Y: $y'; instead.

And this is constructor's initializer list:

LoggingProxy(delegate)
  : mirror = reflect(delegate);
Community
  • 1
  • 1
JAre
  • 4,666
  • 3
  • 27
  • 45
  • #1 derp #2 ahh kinda the same thing but for a constructor? – chrisgotter Aug 09 '14 at 01:19
  • @chrisgotter #2 for example, final fields cannot be initialized in the constructor's body. But, if they depends on constructor's arguments, you can use initializer list. – JAre Aug 09 '14 at 01:34