nim - Working with distinct tuples -


with type defined type brotuple = distinct tuple[a, b, c: int], how can i:

  • create new instance (brotuple() telling me error: 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

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -