You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since it compiles directly to Lua, MoonScript doesn't have a standard library that could include this.
If you want a function similar to JavaScript's prompt, you could try this:
prompt= (text, default) ->io.writetextinput=io.read!
ifinput~=niland#input>0inputelsedefaultage=prompt"How old are you? ", 18print"you are #{age} years old!"-- note: the string interpolation syntax uses #{...}, and @name translates to self.name
Note that JavaScript's prompt will use the default value when the modal is closed without clicking OK. Since the terminal is just text in-and-out, this implementation uses the default value when the input line is empty or the end of the input is reached. (This is more similar to Python's input.)
a function that work's like Typescript's
Code examples
normal usage
pre-set value
The text was updated successfully, but these errors were encountered: