I'm having what seems to be a very simple problem that I simply can't figure out. I have an object containing a seq. If I try to add to that seq I get:
"Error: type mismatch: got (seq[SomeType], SomeType) [...] but expected one of: [...] system.add(x: var seq[T], y: T)"
So I try to change it to 'var seq[SomeType]', but then get:
"Error: invalid type: 'var seq[SomeType]' in this context: 'SomeObject'"
Is there no way to have variable sequences in objects?
type SomeObject = object s: (var) seq[SomeType] var obj = SomeObject(s: @[]) proc someProc(o: SomeObject, a: SomeType) = o.s.add(a)
What's missing is the var in the someProc proc definition:
type
SomeType = object
SomeObject = object
s: seq[SomeType]
var
obj = SomeObject(s: @[])
proc someProc(o: var SomeObject, a: SomeType) =
o.s.add(a)