Day 6 of my journey through Nim. I woke up refreshed and eager to understand the parsecsv module.
Very quickly I got to the point where I wanted to obtain the index position for a particular value in a sequence. A quick search led me to Stack Overflow (https://stackoverflow.com/questions/47638393/nim-find-the-index-of-an-item-in-an-array-or-sequence) and a suggestion to use system.find()
I went to the appropriate docs page and found this:
proc find[T, S](a: T; item: S): int {...}
I stared at that for awhile and then proceeded to try all of the following:
var headers = @["one", "two", "three", "four", "five"]
echo find["three", headers]() # nope
echo headers.find["three"] # nope
echo headers.find("three") # Holy biscuits, YES!!!
echo find(headers, "three") # YAYYYYYY!
I think the docs are great, but this isn't the 1st time I've misunderstood them. Could someone explain to me how I should interpret the syntax that's used? I happened to figure this one out because I happened to glance at the contains proc listed immediately below find in the doc.
find(a, item) >= 0.
This came up before and most procs have examples how to use them, unfortunately find doesn't. Having to assume for every proc that we write that the reader might not understand Nim's basics isn't all that healthy as a development process though, so here is my suggestion:
Read the tutorials. ;-)
(Smiles) RTFM, fair enough.
The advice on what T and S are in the square brackets was useful though. That's all I'm really after, to understand how to read that stole of proc signature.