Created
September 10, 2017 11:26
-
-
Save 10c8/42d3e849251756721666972b014b567a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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