File tree Expand file tree Collapse file tree 1 file changed +39
-1
lines changed
Expand file tree Collapse file tree 1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change 1- ## This Page Is A Work In Progress
1+ Structs is Masterminds equivalent of C structs it is a method of grouping multiple related variables together.
2+ Since Mastermind only supports one primitive data type this means that Structs are collections of one or more cell data types (single or array cells).
3+
4+ Structs can be used to mimic the styles of object orientated code by adding a struct and a series of related functions that
5+ interface with specific structs to almost form a set of class methods. This forms the basis for Masterminds standard library.
6+
7+ Below is example code for how to use Structs
8+
9+ ```
10+ struct box {
11+ cell height;
12+ cell width;
13+ }
14+
15+ def area(struct box boxArg, cell output) {
16+ output = 0;
17+ // height * width
18+ copy boxArg.width {
19+ output += boxArg.height
20+ }
21+ }
22+
23+ sturct box MyBox;
24+ MyBox.height = 12;
25+ MyBox.width = 13;
26+ cell area;
27+ area(MyBox, area);
28+ //area should now equal 156
29+ ```
30+
31+ Below is an example for a struct using arrays
32+
33+ ```
34+ struct grid {
35+ cell x1[3];
36+ cell x2[3];
37+ cell x3[3];
38+ }
39+ ```
You can’t perform that action at this time.
0 commit comments