dart笔记6:重写操作符:
02 | Rectangle a = Rectangle(10, 10); |
03 | Rectangle b = Rectangle(5, 5); |
04 | Rectangle c = Rectangle(10, 10); |
09 | print( '${d.width}--${d.height}' ); |
16 | Rectangle( this .width, this .height); |
19 | bool operator ==(dynamic other) { |
20 | if (other is! Rectangle) { |
23 | Rectangle temp = other; |
24 | return (temp.width == width && temp.height == height); |
28 | Rectangle operator +(dynamic other) { |
29 | if (other is! Rectangle) { |
32 | Rectangle temp = other; |
33 | return Rectangle(temp.width + width, temp.height + height); |
部分素材资源来源网站,本站提供免费下载,如有侵权请联系站长马上删除!