Structs
Structs are loosely modeled after typed JSON literals in JavaScript.
main.w
// Define a simple structure called `Example`
struct Example {
a: str;
b: num;
c: bool?;
}
// Define another structure called `MyData` that includes composition
struct MyData {
a: str;
b: num?;
c: Example;
}
// Creating an instance of `MyData` with some fields initialized
let data = MyData {
a: "hello",
c: Example {
a: "world",
b: 42,
}
};
log(data.a);
log(data.c.a);
log(data.c.b);
Wing console output
# Run locally with wing console
wing it
hello
world
42