/librifox\/.*/
, which only shows files that have librifox/ in the path. Next, I refactored our enumeration handler by pulling all the file traversal logic into a base method that takes functions func_each
for code to be executed for each match, func_done
for code to be executed once all the files had been traversed, and func_error
for any errors that occurred. This is a really flexible way to implement an algorithm that has slight variations in how it works, as I can display all the librifox files in a list view and delete all librifox files with the exact same call pattern, just by varying the functions passed as
func_each
and func_done
.Also, because functions keep the scope they were originally called by, I was able to do the following to check whether any librifox files were present on the device: I'm really glad I'm reading JavaScript: the Good Parts :)
I thought that this was something unique to javascript, but it works in ruby as well! Neat!
Looks like you're ahead of me in reading the book. I just finished chapter 2, but I've already encountered enough gems to make me happy.
ReplyDelete