Add aggregate initialization

This commit is contained in:
Aaron Smith 2023-08-22 11:15:27 +01:00
parent be15f69522
commit 2aebaf5abb
9 changed files with 139 additions and 36 deletions

View file

@ -54,3 +54,17 @@ create "TextButton" {
end
}
```
You can also use a form of aggregate initialization to create datatypes instead
of explicitly typing out the class name and constructor.
```lua
create "Frame" {
AnchorPoint = { 0.5, 1 },
UDim2 = { 0.5, 0, 0.5, 0}
}
```
When a property is assigned a table, Vide will inspect the type of the property
being assigned to, and call that type's default `new()` constructor with the
values from the unpacked table.