From 4c705aa63b1d54b82ab2c70beb693bf4d2cbb7d8 Mon Sep 17 00:00:00 2001 From: Misha Kotwica Date: Fri, 22 Sep 2017 19:33:21 +0200 Subject: [PATCH] ternary operator is possible, seq comprehension in future module, shorthand to array initialization not really possible --- Feature-suggestions.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Feature-suggestions.md b/Feature-suggestions.md index 8e8a3ca..562f8fb 100644 --- a/Feature-suggestions.md +++ b/Feature-suggestions.md @@ -34,6 +34,7 @@ quickly). - a ternary condition - like ?: in C, or iif() - You can do: ``if cond: a else: b``, IIRC the ``?:`` won't make it into Nim. + - A user-defined ternary operator is entirely possible (and really simple). - a simple way of indexing the last element of an array or sequence, to avoid long-hand code like ``arr[arr.len-1]`` - You can do: ``arr[arr.high]`` or ``arr[arr.low]`` for indexing the last and first element or an array or sequence. @@ -43,8 +44,10 @@ quickly). - a shorthand initialization of arrays or sequences, eg var x: array[0..25, int] = -1 would initialize all elements of x to -1 + - Not possible until result type overloading and result-type generic match is introduced to the language. - array/sequence comprehension + - They are present in the ``future`` module of the standard library. - introspection like python's dir()