Ad
Is There A Way To Represent Logical Not With && Or ||
Is there a way to represent logical not, with &&
or ||
or some statement like if
or ?:
I want to implement this in some other way:
boolean isRunning = true;
startButton.setEnabled(!isRunning); // <<== ???
Ad
Answer
Assuming that you are doing this as an exercise, ternary operator lets you replace !
in a simple and straightforward way:
startButton.setEnabled(isRunning ? false : true);
As far as using &&
and ||
by themselves goes, this pair of operators is not functionally complete, i.e. there are operations that cannot be implemented by using a sequence of &&
s and ||
s alone; not !
operation is among operations that cannot be implemented with ands and ors.
Ad
source: stackoverflow.com
Related Questions
- → (Javascript) Take Three Integers From User to Display Sum, Average, Product, Smallest, and Largest Number
- → What is the best way in JavaScript to trim down the properties of an object?
- → How to extend Laravel's bcrypt method
- → Most efficient method to check for range of numbers within number without duplicates
- → What is the best way for me to retrieve this information in a sorted manner?
- → React Page recommends keeping logic at a high level
- → Unexpected undefined Value in JS Script
- → javascript find symmetric difference
- → Does React always check the whole tree?
- → How to use a recursive filter all single JSON data?
- → How is document.querySelector implemented?
- → Algorithm to determine correct character ['╦', '╣', '╠', '╩', '╬'] for intersections in grid
- → Optimal compression for a large base 10 number contained in a string
Ad