Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

An Introduction to Dragon/Lessons/HelloWorld

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Hello World Create a file named hello.dgn: func main() { showln("Hello, World!") } main() showln prints its arguments followed by a newline. Its counterpart, show, prints without a trailing newline. Run the program dragon hello.dgn Any extra arguments after the filename are passed through to the script and become available inside Dragon code as argv. The REPL Dragon also has a persistent interactive session: dragon --repl Variables and functions defined on one line remain available on the next, which makes the REPL convenient for quickly trying things out. Type exit to leave the REPL. Multi-Line literals Backtick strings can span multiple lines and support ${expr} interpolation: name = "Dragon" version = 1.0 showln(`Welcome to ${name} v${version}!`) Getting Input The readln() function reads a line of text typed by the user. See Getting Input for full details. showln("What is your name?") name = readln() showln(`Hello, ${name}!`) Writing Comments Dragon uses C-style comments: // A single-line comment /* A multi-line comment block */