From 4b32b2cef64a408818442acd96b31ecd24a76dd2 Mon Sep 17 00:00:00 2001 From: jlp765 Date: Tue, 3 Jan 2017 12:06:34 +1000 Subject: Tutorial1 additions Add extra For Statement stuff Add Distinct Types --- doc/tut1.rst | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/tut1.rst b/doc/tut1.rst index d896a7044..32faf6168 100644 --- a/doc/tut1.rst +++ b/doc/tut1.rst @@ -380,6 +380,28 @@ Since counting up occurs so often in programs, Nim also has a `.. for i in 1..10: ... +Zero-indexed counting have two shortcuts ``..<`` and ``..^`` to simplify counting to one less then the higher index: + +.. code-block:: nim + for i in 0..<10: + ... # 0..9 + +or + +.. code-block:: nim + var s = "some string" + for i in 0.. a at index 0 + # => b at index 1 Scopes and the block statement ------------------------------ @@ -1516,8 +1538,14 @@ Example: A subtle issue with procedural types is that the calling convention of the procedure influences the type compatibility: procedural types are only compatible if they have the same calling convention. The different calling conventions are -listed in the `manual `_. +listed in the `manual `_. +Distinct type +------------- +A Distinct type allows for the creation of new type that "does not imply a subtype relationship between it and its base type". +You must EXPLICITLY define all behaviour for the distinct type. +To help with this, both the distinct type and its base type can cast from one type to the other. +Examples are provided in the `manual `_. Modules ======= -- cgit 1.4.1-2-gfad0