Can someone explain to me how I can use the values returned by a spawned function?
import threadpool
proc myTest(s: string): int =
echo s
return s.len
proc main() =
let x = spawn myTest("Hello")
let y = spawn myTest("World")
sync()
let z = x + y
echo $z
main()
After trying to compile the code it gives this error:
/home/hdias/devel/test.nim(12, 13) Error: type mismatch: got <FlowVar[system.int], FlowVar[system.int]>
but expected one of:
proc `+`(x, y: float): float
...
proc `+`[T](x, y: set[T]): set[T]
first type mismatch at position: 1
required type for x: set[T]
but expression 'x' is of type: FlowVar[system.int]
expression: x + y