it mirrors the structure below. In my use case the "sections" are not known at runtime, nor how many books in a section.
I need to be able to loop through the books in a given section sequentially and access a book by index arbitrarily.
I could use a loop until an index that does not exist, use loop, books["section"].Length() and A_Index
both of those seem like I'm missing some thing obvious, where a for loop seems like the natural way to do what I need, but I'm pushing new objects into an object so they have no associative key.
It might just be the case that for loops are semantically looping through keys and I dont have an "each" and I'm connecting dots that dont connect.
So, do I skip the For loop here and foll my own loop?
Code: Select all
books := Object()
books["fiction"] := Object()
loop, 5
{
book := Object()
book["title"] := "book" . A_Index
books["fiction"].push(book)
}
loop, 5
{
msgbox % books["fiction"][A_Index]["title"]
}