Hi,
I still get tripped up by this. Why is it that some templates allow me to write
using dot notation, and others do not? Is it that the ones that do not allow
dot notation have untyped parameters? - Why would that affect it? My current
workflow is to memorize the list of UFCable templates by trial and error, which
is annoying. I'm hoping to find a better answer for when introducing nim to
others.
import sequtils, tables
var a = {0:10,1:20,2:30}.toTable()
withValue(a, 1, value) do: # OK function call use of template
value[] = 11
a.withValue(1, value) do: # OK method call use of template
value[] = 11
echo toSeq(a.pairs) # OK function call use of template
echo a.pairs.toSeq() # ERROR method call use of template
# maybe the dot notation with iterator is confusing the compiler...
echo pairs(a).toSeq() # ERROR nope, still doesn't work
Run
Thanks!