nim - Working with distinct tuples -
with type defined type brotuple = distinct tuple[a, b, c: int]
, how can i:
create new instance (
brotuple()
telling meerror: object constructor needs object type
)access fields (
proc example(br: brotuple) = echo br.a
says:error: undeclared field: 'a'
)
it's bit strange use distinct tuple, because intent of distinct
hide accessors , procs have. should use object instead if goal prevent ambiguity other tuples/objects.
if want it, here go:
type brotuple = distinct tuple[a, b, c: int] var bro = brotuple((a: 0, b: 0, c: 0)) echo((tuple[a, b, c: int])(bro).a)
Comments
Post a Comment