#unwrap multiple optionals in one if
1 messages · Page 1 of 1 (latest)
You could do
blk: {
const x1 = v1.x orelse break :blk;
const y1 = v1.y orelse break :blk;
const x2 = v2.x orelse break :blk;
const y2 = v2.y orelse break :blk;
draw.line(x1, y1, x2, y2);
}```
itd have to be blk: { and break :blk;
i wanna only not draw the lines where a point is missing
Ah forgot that sorry
this is breaking out of a block, not a loop
You could also do
if (v1.x != null and v1.y != null and v2.x != null and v2.y != null) draw.line(v1.x.?, v1.y.?, v2.x.?, v2.y.?);```
yep thats better