| 1 | == Extended Initialization == |
| 2 | |
| 3 | Allows setting of class instance property values in instance constructor call. |
| 4 | Given |
| 5 | |
| 6 | {{{ |
| 7 | use System.Drawing |
| 8 | class Rectangle |
| 9 | var _p1 as Point |
| 10 | var _p2 as Point |
| 11 | |
| 12 | pro p1 from var |
| 13 | pro p2 from var |
| 14 | |
| 15 | def toString as String is override |
| 16 | return 'Rect{[.p1],[.p2]}' |
| 17 | }}} |
| 18 | Then |
| 19 | {{{ |
| 20 | r = Rectangle(p1=Point(x=0, y=1), p2=Point(x=2, y=3)) |
| 21 | c = Customer('Acme, Inc.', region=Regions.South) |
| 22 | }}} |
| 23 | |
| 24 | is approx equiv to |
| 25 | |
| 26 | {{{ |
| 27 | r = Rectangle() |
| 28 | p1=Point() |
| 29 | p1.x=0 |
| 30 | p1.y=1 |
| 31 | r.p1 = p1 |
| 32 | p2=Point() |
| 33 | p2.x=2 |
| 34 | p2.y=3 |
| 35 | r.p2 = p2 |
| 36 | |
| 37 | c = Customer('Acme, Inc.') |
| 38 | c.region=Regions.South |
| 39 | }}} |
| 40 | |