Is There A Way To Represent Logical Not With && Or ||
Is there a way to represent logical not, with
|| or some statement like
I want to implement this in some other way:
boolean isRunning = true; startButton.setEnabled(!isRunning); // <<== ???
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
|| 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 alone; not
! operation is among operations that cannot be implemented with ands and ors.
- → 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
- → 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