find field value object in seq and declared object in seq

2024-05-20 Thread ingo
Thank you both. Enough to fiddle with. The goal is to find the index of the first occurrence of Box(food: value), if at all. Like `seq.find(value)` Cheers.

find field value object in seq and declared object in seq

2024-05-20 Thread Isofruit
Not entirely sure what exactly you want findInObjSeq to do. Is this supposed to return you a count? An Index? An instance from the list? Either way, if you want to get past this entirely without macros you will need to make use of the `when` keyword instead of "if". And also the fieldpairs iter

find field value object in seq and declared object in seq

2024-05-20 Thread janAkali
>From your example it seems that you want to count quantity of specified items >in seq. You can do this easily with `sequtils.countIt`: import std/sequtils echo c1.content.countIt(it.food == true) # 3 Run If you don't need a count and only want to check if item is

find field value object in seq and declared object in seq

2024-05-20 Thread ingo
How does one find out whether a field in an object in an array exists? The commented out `echo declared(c1.content[0].thing)` errors. How do I find whether a value in a field of an object in an array exists using a proc, or template? The commented out code shows my failure. type