Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added section on comments, Added strutils example to strings #71

Merged
merged 3 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions content/content/comments.md
Original file line number Diff line number Diff line change
@@ -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"
```
21 changes: 21 additions & 0 deletions content/content/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions content/content/toc.md
Original file line number Diff line number Diff line change
@@ -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/)
Expand Down