[nim-dev] Re: Constructors via typedesc[] arguments

  • From: Krux02 <arne.doering@xxxxxxx>
  • To: nim-dev@xxxxxxxxxxxxx
  • Date: Tue, 6 Dec 2016 17:59:04 +0000

I like the pattern. You probably already know it and just wanted to make the 
example simple, but you can keep the ref version generic:

```Nim
proc new[T](typ:typedesc[T], name:string, age:int):ref T =
  result.new()
  result[] = typ.val(name, age)
```


Other related posts: