summaryrefslogtreecommitdiffhomepage
path: root/nim.html.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'nim.html.markdown')
-rw-r--r--nim.html.markdown23
1 files changed, 16 insertions, 7 deletions
diff --git a/nim.html.markdown b/nim.html.markdown
index 5d00304d..9730e579 100644
--- a/nim.html.markdown
+++ b/nim.html.markdown
@@ -12,10 +12,23 @@ that gives the programmer power without compromises on runtime efficiency.
Nim is efficient, expressive, and elegant.
```nim
+# Single-line comments start with a #
+
+#[
+ This is a multiline comment.
+ In Nim, multiline comments can be nested, beginning with #[
+ ... and ending with ]#
+]#
+
+discard """
+This can also work as a multiline comment.
+Or for unparsable, broken code
+"""
+
var # Declare (and assign) variables,
letter: char = 'n' # with or without type annotations
lang = "N" & "im"
- nLength : int = len(lang)
+ nLength: int = len(lang)
boat: float
truth: bool = false
@@ -35,10 +48,6 @@ when compileBadCode: # `when` is a compile time `if`
discard 1 > 2 # Note: The compiler will complain if the result of an expression
# is unused. `discard` bypasses this.
-discard """
-This can work as a multiline comment.
-Or for unparsable, broken code
-"""
#
# Data Structures
@@ -76,7 +85,7 @@ let myDrink = drinks[2]
# static typing powerful and useful.
type
- Name = string # A type alias gives you a new type that is interchangable
+ Name = string # A type alias gives you a new type that is interchangeable
Age = int # with the old type but is more descriptive.
Person = tuple[name: Name, age: Age] # Define data structures too.
AnotherSyntax = tuple
@@ -109,7 +118,7 @@ when compileBadCode:
type
Color = enum cRed, cBlue, cGreen
- Direction = enum # Alternative formating
+ Direction = enum # Alternative formatting
dNorth
dWest
dEast