How do I store a boolean test/expression without Evaluating it?

Mxt

So I'd like to be able to store a boolean test without storing the value (true/false), I'd like to be able to pass multiple of these boolean tests through methods. Possibly even switching arguments and operators. Is there anyway to do this?

I've seen some people save them as Strings then use Interpreter from BeanShell, but is there another way? Or should I try my best at creating a way to do this?

ajb

In Java 8, you can use a lambda. java.util.function has a number of classes that represent functions that return booleans (Predicate, BiPredicate, IntPredicate, DoublePredicate, etc.), and those types can be used to hold an expression that returns a boolean. Example:

BiPredicate<Integer,Integer> pred = (x, y) -> x > y;

Now pred contains a function that tests whether the first integer is greater, but that function isn't actually evaluated until you use something like

boolean result = pred.test(arg1, arg2);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I dump yaml without evaluating anchor values?

How can I get the Boolean value from an ng-show attribute without re-evaluating the expression?

How can I store a function, like < or >= as a value for evaluating it later, in CLIPS?

How should I store boolean values in mongodb?

How do you split a Django queryset without evaluating it?

How do I display true if the member variable is off, without changing the type from void to boolean?

How do I turn arguments 'integer<120 boolean boolean boolean boolean' into the most compact package possible

(Boolean/SFML) How do I create a boolean that checks collision?

How do I "default" a boolean property in JavaScript?

How do I assign a boolean object to a value?

How do I shorten this boolean expression?

How do I use a Boolean in Python?

How do I return a boolean from AsyncTask?

How do I concatenate a boolean to a string in Python?

How do I concatenate a boolean to a string in Python?

How do I convert a boolean to an integer in Rust?

How do I use boolean variables in Perl?

How do I check a value in a boolean List?

How do I use a boolean Value as Trigger

How do I simplify(expand) this Boolean expression?

How do I toggle boolean field

how do i convert the working hours to Boolean?

How do I print the boolean value?

How do I store numbers in C++ without the decimals being truncated?

How do I force set the user context without a key value store or wallet?

How do I wait for a subprocess to finish, store it's output and add a prefix (without a new line) to the output?

How do I store a vector of std::bind without a specific case for the template?

How do I store an integer correctly in the SharedPrefences in Flutter without getting a null?

How do I store a large int in python without the newlines being counted by len()?