Data structures added

This commit is contained in:
Federico Ceratto 2015-04-06 17:04:08 +01:00
parent 3efa9fb6a8
commit 76049d9729
1 changed files with 15 additions and 2 deletions

View File

@ -108,6 +108,19 @@ That will return a compilation error, because the objects have different sizes.
So, when using inheritance, be sure to inherit using refs, unless you know what you are doing. Also, check out Nim's generic programming capabilities as an alternative to OOP and inheritance.
### Structs - Tuples and Objects
## Data structures
Tuples are entirely different from Python
### Python tuples
Nim Tuples are close to Python nametuples, see [manual](http://nim-lang.org/manual.html#tuples-and-object-types)
### Python sets
Python sets are not like [Nim set type](http://nim-lang.org/manual.html#set-type).
If the values that will go in the set are known beforehand and finite, you can create an Enum for them.
Otherwise you can emulate a Python set using a [HashSet](http://nim-lang.org/sets.html).
The Nim set type is faster and memory-efficient.
### Dictionaries
Use [HashSet](http://nim-lang.org/sets.html)