diff --git a/content/content/comments.md b/content/content/comments.md new file mode 100644 index 0000000..2ce71fa --- /dev/null +++ b/content/content/comments.md @@ -0,0 +1,20 @@ +--- +title: Comments +--- +# Comments + +Comments in Nim begin with the hash character. + +```nimrod +# This is a comment +echo "This is code" # This is another comment +``` + +Multiline or block comments begin with the hash and square bracket, `#[`, and are terminated with a closing square bracket followed by a hash, `]#`. Multi line comments can be nested. + +```nimrod +#[ This is a multi line comment +it continues until it is terminated +]# +echo "This is code" +``` diff --git a/content/content/strings.md b/content/content/strings.md index 2c7a719..1ee6f4d 100644 --- a/content/content/strings.md +++ b/content/content/strings.md @@ -45,6 +45,27 @@ Strings can also almost be thought of as `seq[char]` with respect to assignment [seqs]: /seqs/#immutability +The `strutils` module provides procs for handling strings. + +``` nimrod +import strutils + +var a = "hello welcome,friend" + +# The split proc takes a sequence of characters and splits a string based on them +echo a.split({' ', ','}) + +# The contains proc determines whether a string contains a substring or character +echo a.contains("hello") + +``` + +``` console +$ nim c -r strutils.nim +@["hello", "welcome", "friend"] +true +``` + ## A note about Unicode Unicode symbols are allowed in strings, but are not treated in any special way, so if you want count glyphs or uppercase Unicode symbols, you must use the `unicode` module. diff --git a/content/content/toc.md b/content/content/toc.md index cc91089..ede46ab 100644 --- a/content/content/toc.md +++ b/content/content/toc.md @@ -1,5 +1,6 @@ * [Getting Started](/getting_started/) * [Hello World](/hello_world/) +* [Comments](/comments/) * [Variables](/variables/) * [Result](/variables/result/) * [Type Casting and Inference](/variables/type_casting_inference/)