Hi all again!
I want to use filter function on keys of some table, so i wrote this code:
my_very_own_table.keys.to_seq.filter( ... )
but instead of executable i get this error:
Error: undeclared field: 'keys'
found *list of iterators with same name*
Why i get this? Because in for loop it works as usual...
I'm on my phone right now, so I won't try to find the correct issues.
This is a problem of toSeq in combination with method UFCS. Call the keys iterator as a normal function call to toSeq and it should work.
Actually it does not... Error is almost the same:
Error: attempting to call routine: 'keys'
Im using 1.0.6 version of nim compiler RN
Does your code look like this https://play.nim-lang.org/#ix=2hIK ?
You have to wrap my_very_own_table.keys in a toSeq call because .keys is an iterator
Maybe you're getting a variable of Table type from some other module in your project and in the current module you forgot to import tables? That wouldn't work:
# a.nim
import tables
proc test*(data: string): Table[string, string] =
result = {data: "test"}.toTable()
# b.nim
import sequtils
import a
let tableData = test("hello")
echo toSeq(tableData.keys) # error because we didn't import tables
If you have the same issue as I described above, you can solve it by:
Oh lord, you right! NRE module interfered! After it's deletion everything is alright.
Thank you!