Updated Nim for Python Programmers (markdown)
This commit is contained in:
parent
6c15143548
commit
fb065f5088
|
@ -106,7 +106,7 @@ var c = Cat(name: "Tom")
|
||||||
c.increase_age()
|
c.increase_age()
|
||||||
echo c.name, " ", c.age
|
echo c.name, " ", c.age
|
||||||
```
|
```
|
||||||
|
Tip: use objects by reference
|
||||||
|
|
||||||
### Inheritance
|
### Inheritance
|
||||||
|
|
||||||
|
@ -130,7 +130,14 @@ So, when using inheritance, be sure to inherit using refs, unless you know what
|
||||||
|
|
||||||
### Python tuples
|
### Python tuples
|
||||||
|
|
||||||
Nim Tuples are close to Python nametuples, see [manual](http://nim-lang.org/manual.html#tuples-and-object-types)
|
Nim Tuples are close to Python nametuples, see [manual](http://nim-lang.org/manual.html#tuples-and-object-types).
|
||||||
|
Use Nim arrays:
|
||||||
|
``` Nim
|
||||||
|
var a = ["hi", "there"]
|
||||||
|
var b = [1, 2, 3]
|
||||||
|
echo b[1]
|
||||||
|
var c = ["hi", 1] # no mixed types please
|
||||||
|
```
|
||||||
|
|
||||||
### Python sets
|
### Python sets
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue