"Fix" examples and add TODOs for later syntax
This commit is contained in:
parent
9c1709e134
commit
01bb85d386
|
@ -4,11 +4,12 @@ interface Update {
|
|||
}
|
||||
|
||||
struct Clock12Hr {
|
||||
bool pm = true,
|
||||
u8 hours = 12,
|
||||
u8 minutes = 0,
|
||||
u8 seconds = 0,
|
||||
f64 sub = 0.0,
|
||||
// TODO structure member initialization expressions
|
||||
bool pm, // = true,
|
||||
u8 hours, // = 12,
|
||||
u8 minutes, // = 0,
|
||||
u8 seconds, // = 0,
|
||||
f64 sub, // = 0.0,
|
||||
}
|
||||
|
||||
impl Clock12Hr {
|
||||
|
@ -32,8 +33,10 @@ impl Clock12Hr {
|
|||
.hours = .hours + 1;
|
||||
if .hours >= 13 {
|
||||
.hours = 1;
|
||||
} else if hours == 12 {
|
||||
.hours = not .hours;
|
||||
} else { // TODO else-if statements
|
||||
if hours == 12 {
|
||||
.pm = not .pm;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ struct World {
|
|||
u32 numdots,
|
||||
BitArray next,
|
||||
|
||||
// members can have default initialization values
|
||||
i32 xmin = 1'000'000,
|
||||
i32 xmax = -1,
|
||||
i32 ymin = 1'000'000,
|
||||
i32 ymax = -1,
|
||||
// TODO member default initialization
|
||||
i32 xmin, // = 1'000'000,
|
||||
i32 xmax, // = -1,
|
||||
i32 ymin, // = 1'000'000,
|
||||
i32 ymax, // = -1,
|
||||
}
|
||||
|
||||
// non-associated function, operates in the scope of its arguments only
|
||||
|
@ -47,7 +47,8 @@ World mut fn set_next(i32 i, i32 j) {
|
|||
if neighbors != 3 {
|
||||
0
|
||||
} else {
|
||||
numdots++;
|
||||
// TODO binary operator assignment shorthand
|
||||
numdots = numdots + 1;
|
||||
1
|
||||
}
|
||||
} else {
|
||||
|
@ -55,7 +56,8 @@ World mut fn set_next(i32 i, i32 j) {
|
|||
if neighbors == 2 or neighbors == 3 {
|
||||
1
|
||||
} else {
|
||||
numdots--;
|
||||
// TODO binary operator assignment shorthand
|
||||
numdots = numdots - 1;
|
||||
0
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue