Skip to content

Instantly share code, notes, and snippets.

@10c8
Created September 10, 2017 11:26
Show Gist options
  • Save 10c8/42d3e849251756721666972b014b567a to your computer and use it in GitHub Desktop.
Save 10c8/42d3e849251756721666972b014b567a to your computer and use it in GitHub Desktop.
type
Type[T] = object of RootObj
typeName: string
value: T
String* = ref object of Type[string]
proc newString*(value: string): String =
result = String(typeName: "String",
value: value)
let val: string = "test"
# Works:
let str: String = newString(val)
# Doesn't compile:
const str_const: String = newString(val_const)
# => (line 9) Error: cannot create null element for: [T]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment