Skip to content

Commit

Permalink
feat(docs): adding learn by for Wing
Browse files Browse the repository at this point in the history
  • Loading branch information
David Boyne authored and David Boyne committed Aug 27, 2024
1 parent f57f78a commit d41202d
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions example_versioned_docs/version-latest/10-structs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: Structs
id: structs
slug: /structs
sidebar_label: 10. Structs
description: Using arrays with Wing
keywords: [Wing language, example]
---

Structs are loosely modeled after typed JSON literals in JavaScript.

```js playground example title="main.w"
let main = () => {

let a = MutArray<num>[1, 2, 3];

log("{a[0]}, {a[1]}, {a[2]}");

a[2] = 4;

log("mutated value: {a[2]}");
log("len: {a.length}");

let data = MutArray<num>[1, 2, 3];
let twoD = MutArray<MutArray<num>>[data];

for array in twoD {
for item in array {
log(item * 10);
}
}

}

```

```bash title="Wing console output"
# Run locally with wing console
wing it

1, 2, 3
mutated value: 4
len: 3
10
20
30
```

0 comments on commit d41202d

Please sign in to comment.