From 80992c7a1258d6ae0e0f322f3be0a1b955a96774 Mon Sep 17 00:00:00 2001 From: Arne Döring Date: Thu, 14 Feb 2019 22:17:05 +0100 Subject: introduce object before tuple in the tutorials (#10664) --- doc/tut1.rst | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 93 insertions(+), 15 deletions(-) (limited to 'doc/tut1.rst') diff --git a/doc/tut1.rst b/doc/tut1.rst index a7f1b741a..161b4b904 100644 --- a/doc/tut1.rst +++ b/doc/tut1.rst @@ -1441,31 +1441,111 @@ string that is "useless" and replace it with "useful". Note: alternate ways of writing this are ``b[^8..^2] = "useful"`` or as ``b[11..b.len-2] = "useful"`` or as ``b[11.. Error: type mismatch: got (tuple[street: string, number: int]) # but expected 'Person' - # The following works because the field names and types are the same. - var teacher: tuple[name: string, age: int] = ("Mark", 42) - person = teacher - Even though you don't need to declare a type for a tuple to use it, tuples created with different field names will be considered different objects despite having the same field types. @@ -1519,6 +1595,8 @@ variables! For example: echo badname echo badext +Fields of tuples are always public, they don't need to be explicity +marked to be exported, unlike for example fields in an object type. Reference and pointer types --------------------------- -- cgit 1.4.1-2-gfad0