summary refs log tree commit diff stats
path: root/doc/tut1.txt
diff options
context:
space:
mode:
authorMiguel <leu-gim@moy-server.ru>2014-02-10 01:20:42 +0400
committerMiguel <leu-gim@moy-server.ru>2014-02-10 01:20:42 +0400
commiteb9964fbbb9e1311edd72fcd6d47048db6178ed6 (patch)
tree402a1dcbfc2dd4bea122cd27d233ded67309c7ed /doc/tut1.txt
parenta8b4e3c764dd967e1ac90305a574c4cd5e0d019b (diff)
parente478374e0d16cf42051e753ccdd364aec13cf7d7 (diff)
downloadNim-eb9964fbbb9e1311edd72fcd6d47048db6178ed6.tar.gz
Merge branch 'devel' of git://github.com/Araq/Nimrod
Diffstat (limited to 'doc/tut1.txt')
-rw-r--r--doc/tut1.txt24
1 files changed, 24 insertions, 0 deletions
diff --git a/doc/tut1.txt b/doc/tut1.txt
index 1ba3253c8..b70f40f4a 100644
--- a/doc/tut1.txt
+++ b/doc/tut1.txt
@@ -1321,6 +1321,30 @@ In this example ``$`` is applied to any argument that is passed to the
 parameter ``a``. Note that ``$`` applied to strings is a nop.
 
 
+Slices
+------
+
+Slices look similar to subranges types in syntax but are used in a different
+context. A slice is just an object of type TSlice which contains two bounds,
+`a` and `b`. By itself a slice is not very useful, but other collection types
+define operators which accept TSlice objects to define ranges.
+
+.. code-block:: nimrod
+
+  var
+    a = "Nimrod is a progamming language"
+    b = "Slices are useless."
+
+  echo a[10..15] # --> 'a prog'
+  b[11.. -2] = "useful"
+  echo b # --> 'Slices are useful.'
+
+In the previous example slices are used to modify a part of a string, and even
+a negative index is used. The slice's bounds can hold any value supported by
+their type, but it is the proc using the slice object which defines what values
+are accepted.
+
+
 Tuples
 ------