So I ran into a thing today, where there was a rea...
# cfml-general
t
So I ran into a thing today, where there was a really odd behavior.
Copy code
list = DirectoryList(Expand("./"), false, "name", "*.log");
 for( i = 1; i <= list.len(); i++ ) {
    WirteDump(list[i]);
}
will list the files
Copy code
list = DirectoryList(Expand("./"), false, "name", "*.log");
 for( file in list ) {
    WriteDump(file);
}
outputs an empty struct.
And
Copy code
list = DirectoryList(Expand("./"), false, "name", "*.log");
 for( file in list ) {
    WriteDump(file.toString());
}
gives me
{}
and if I try and use
file
it complains that it's not a simple variable.
Anyone run into this before, and know what's up? (This is CF2023, btw)
r
what is the value of
list
?
m
change file to something else, it's a key used by cf
👍🏻 1
👍 1
r
Although the following works.
Copy code
list = directoryList(expandPath("./"), false, "name", "*.log");

list.each((file) => {
    writeDump(file);
});
Probably because it's really arguments.file. 🤷
t
🤦‍♂️
Thanks