Try as I might, I have been unable to comprehensively understand the difference between the filter operator and the subfilter operator. I’m sure there is a difference and maybe it’s just the way I’ve been using them, but I’m just not getting it. Could someone help explain the difference(s)?
I like to think that the subfilter does what I would expect a filter to do, and filter does what I would expect a subfilter to do.
The subfillter filter operator allows you to use a filter defined outside the filter expression as if it were part of the expression. It continues the existing filter run, and it’s output is added to the output just like a regular filter operator.
A filter filter operator makes a decision about what items in the current title list will be kept, and which will be discarded. For instance, you might have a series of tiddlers that represent employees, with a list fields for hours worked every day of the week. Your filter might add up all the hours for each employee and compare with 32. If less, it lets them through. If more, it doesn’t. The numerical results (the calculations) are not passed on.
Yes. The fitler operator discards the result of the subfilter and returns the input title. The subfilter operator returns the results of the subfilter.
As a result, I now tend to use them according to both their features but also if they sound right in English. Eg subfilter is more of a subset, where filter is a set.
The filter will only return those railroads chartered in the state of Nebraska. If I replace the subfilter operator with the filter operator, I get the exact same results. I also get the same results with:
[tag[Railroads]] :filter[statefiled[Nebrasaka]]
So far, this is the only way I’ve used them, so maybe I am not using them in a way that highlights their differences.
Your variable-filter filt doesn’t change the input, only tests it for pass/fail and and returns the passing tiddler titles. So the result would be the same when using both fitler and subfilter operators.
In some cases the two filters will give the same result, like @joshuafontany said.
https://tiddlywiki.com/#filter%20Operator%20(Examples) - go to this tiddler and click the try it button for some of the examples and edit the filter back and forth between subfilter and filter. You should see the output change. Maybe those concrete examples will help make it clear?
Phew! I think I finally understand now especially after doing what @btheado suggested and seeing what the differences are. Thanks to everyone who helped me out with this. Now the trick is going to be remembering next week!