module_with_generics.nim 257 B

123456789101112131415
  1. type
  2. Base[T] {.inheritable.} = ref object
  3. value*: T
  4. Derived[T] = ref object of Base[T]
  5. derivedValue*: T
  6. proc makeDerived*[T](v: T): Derived[T] =
  7. new result
  8. result.value = v
  9. proc setBaseValue*[T](a: Base[T], value: T) =
  10. a.value = value