2021-02-18【Dart】语法记录

1.命名构造函数

class Rect
{
  const Rect.posAndSize(this.pos, this.size); //命名构造函数
/// Gets the empty rectangle.
  static const empty = Rect.posAndSize(Vec.zero, Vec.zero);
}

c#改写:可以使用静态函数:

        public static RoomTile Junction(Direction direction)
        {
            var rtn = new RoomTile()
            {
                tile = null,
                direction = direction
            };
            return rtn;
        }

你可能感兴趣的:(2021-02-18【Dart】语法记录)