How to return a named predicates
Hi friends,
I want to build a
Method
that returns a set of Predicates
Example:
The Issue:
How do I can return those predicates but everyone with a name like properties, let me explain more
depending on the example I provided the use of that result will be like this:
as you will notice that to get every predicate I should use its index
, instead of that I want when I got the predicates use their names like this following
I hope the explanation of the issue is clear, please is this even possible, if yes how do I can achieve this ? and massive thanks.8 Replies
you will want to make a
class
that contains properties with your desired names that provides access to these predicates
or return a named tuple, but that's yuckyhmmm, the problem is this method will works
generically
and the names of predicate
s will not be fixedthen I think you're out of luck
if you want to use names at compile time, you have to know the names at compile time
hmmmm so this maybe impossible right ?
unless i'm missing something, and you don't wanna make a new class, then yeah i think so
this be done using
Anonymous types
?possibly
i don't mess around with those too much
Make a class with normal properties (as already said), or return a dict and use string or enum as the key