summary refs log tree commit diff stats
path: root/tests/niminaction/Chapter1/various1.nim
blob: 688180fd2b2a33f63fbc6d109e3a5507748bff78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
discard """
  exitCode: 0
  outputsub: "Woof!"
"""

import strutils
echo("hello".to_upper())
echo("world".toUpper())

type
  Dog = object #<1>
    age: int #<2>

let dog = Dog(age: 3) #<3>

proc showNumber(num: int | float) =
  echo(num)

showNumber(3.14)
showNumber(42)

for i in 0 .. <10:
  echo(i)

block: # Block added due to clash.
  type
    Dog = object

  proc bark(self: Dog) = #<1>
    echo("Woof!")

  let dog = Dog()
  dog.bark() #<2>

import sequtils, future, strutils
let list = @["Dominik Picheta", "Andreas Rumpf", "Desmond Hume"]
list.map(
  (x: string) -> (string, string) => (x.split[0], x.split[1])
).echo

import strutils
let list1 = @["Dominik Picheta", "Andreas Rumpf", "Desmond Hume"]
for name in list1:
  echo((name.split[0], name.split[1]))