We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c79d769 commit 1014bfaCopy full SHA for 1014bfa
src/interpreter.ts
@@ -273,12 +273,14 @@ export class Interpreter {
273
}),
274
});
275
276
- setFn("ask", (question: any) => {
+ setFn("ask", (question: any = "", zero?: any) => {
277
MainLoop.stop(); // FIXME: find another way to make this sync, please!
278
let input = prompt(String(question)); // FIXME: rework into asynchronous style!
279
MainLoop.start(); // FIXME:
280
281
- return input;
+ if (typeof zero == "number") return +(input || zero);
282
+ if (typeof zero == "boolean") return !!(input || zero);
283
+ return input || zero;
284
285
286
setFn("print", (...words: any[]) => {
0 commit comments