summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorjemcroft <jemcroft@gmail.com>2014-12-13 12:28:34 +1000
committerjemcroft <jemcroft@gmail.com>2014-12-13 12:32:42 +1000
commitc1478e6c1aa6ce63ac6597df212e654fd01322a3 (patch)
tree1486212ebf8350edff2d8f61865e9e55efe61682
parent516c6dafe27b7dde5b9fa5d1b817c13d445c3277 (diff)
downloadNim-c1478e6c1aa6ce63ac6597df212e654fd01322a3.tar.gz
Adding type conversion examples to the tutorial
-rw-r--r--doc/tut1.txt13
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/tut1.txt b/doc/tut1.txt
index 1a6530e6c..3b2e92c30 100644
--- a/doc/tut1.txt
+++ b/doc/tut1.txt
@@ -957,6 +957,19 @@ versa. The `toInt <system.html#toInt>`_ and `toFloat <system.html#toFloat>`_
 procs can be used for these conversions.
 
 
+Type Conversion
+---------------
+Conversion between basic types in nim is performed by using the
+type as a function:
+
+.. code-block:: nim
+  var
+    x: int32 = 1.int32   # same as calling int32(1)
+    y: int8  = int8('a') # 'a' == 97'i8
+    z: float = 2.5       # int(2.5) rounds down to 2
+    sum: int = int(x) + int(y) + int(z) # sum == 100
+
+
 Internal type representation
 ============================