Implement state unset
This commit is contained in:
parent
ea7889726c
commit
e52ce64bce
@ -138,7 +138,7 @@ const codeHtml = highlightCode(trimAndDedent(code));
|
||||
</div>
|
||||
|
||||
<script>
|
||||
type Instruction = "line" | "out" | "set";
|
||||
type Instruction = "line" | "out" | "set" | "unset";
|
||||
type AlpineState = {
|
||||
line: number,
|
||||
stdout: string,
|
||||
@ -170,6 +170,10 @@ const codeHtml = highlightCode(trimAndDedent(code));
|
||||
data.state[String(instructionArr[1])] = String(instructionArr[2]);
|
||||
break;
|
||||
}
|
||||
case "unset": {
|
||||
delete data.state[String(instructionArr[1])];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,17 +86,21 @@ Use a naked `try` when you want to rethrow an error, if there is any.
|
||||
steps={`[
|
||||
[["line", 14]],
|
||||
[["line", 7]],
|
||||
[["line", 10]],
|
||||
[
|
||||
["line", 10],
|
||||
["set", "Int result", "..."]
|
||||
],
|
||||
[["line", 1]],
|
||||
[["line", 3]],
|
||||
[
|
||||
["line", 10],
|
||||
["set", "result", 50]
|
||||
["set", "Int result", "Int 50"]
|
||||
],
|
||||
[["line", 11]],
|
||||
[
|
||||
["line", 14],
|
||||
["out", "The result is 50\\n"],
|
||||
["unset", "Int result"],
|
||||
],
|
||||
[
|
||||
["line", 15],
|
||||
|
Loading…
Reference in New Issue
Block a user