What does '!!~' do in Javascript?
indexOf
will return the index 0-x
if the element is found, -1
otherwise.
~
will change all the bits in the number, turning -1
to 0
(the binary represantation of -1
is 1111 1111 ...
).
0
is a falsy value, all other numbers are truthy.
!!
will convert a falsy value to false
and a truthy value to true
. It wouldn't be needed here, because every
doesn't care whether it recieves a truthy value or true.
As others have mentioned, nowadays you could use includes
. However, includes
is newer to the JavaScript ecosystem than indexOf
, so this solution would work in IE, the solution with include
would not. You could still use includes
in IE either by providing a polyfill or by transpiling your code.
What does *= do?
The *=
operator is called multiplication assignment operator and is shorthand for multiplying the operand to the left with the operand to the right and assigning the result to the operand to the left. In this case, it's the same as:
x = x * 2;
Here integer promotion first takes place and the result of x * 2
is indeed 260
.
However, an unsigned char
can usually only carry values between 0 and 255 (inclusive) so the result overflows (wraps around) when you try assigning values above 255 and 260 % 256 == 4.
What does :: do?
::
is a scope resolution operator, it effectively means "in the namespace", so ActiveRecord::Base
means "Base
, in the namespace of ActiveRecord
"
A constant being resolved outside of any namespace means exactly what it sounds like - a constant not in any namespace at all.
It's used in places where code may be ambiguous without it:
module Document
class Table # Represents a data table
def setup
Table # Refers to the Document::Table class
::Table # Refers to the furniture class
end
end
end
class Table # Represents furniture
end
What does the python operator =- do?
Actually, the operator =-
does not exist. It is only = (- value)
. So the negative of the value.
Example:
>>> x =- 1
>>> x
-1
What does '= ' do in C#?
The =>
operator designates a Lambda Expression:
A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.
All lambda expressions use the lambda operator =>, which is read as "goes to". The left side of the lambda operator specifies the input parameters (if any) and the right side holds the expression or statement block. The lambda expression x => x * x is read "x goes to x times x." This expression can be assigned to a delegate type as follows:
static void Main(string[] args)
{
Func<int, int> func = x => x * x;
int j = func(5);
// j == 25
}
What does ! do in Flutter/Dart?
The exclamation mark is a dangerous but powerful operator.
It tells the compiler to assume the value is not null.
When you do this, the type gets cast from a nullable to a non-nullable type, and can be used in places that accept only non-nullable values.
When you do this, you must entirely trust your code not to accidentally use a null value.
More information in this question/answer.
In your specific situation, we can be sure that the value is not null because of your if statement that checks this.
Because of this, I would imagine you can just use _selectedFile
without any additional operator. When you do this, you force the compiler to prove the safety of your code, rather than you just trusting yourself. If the compiler is satisfied, the code will compile. I haven't used Dart, so I don't know how smart the compiler is, but hopefully it can handle this circumstance without requiring you to take a risk with the !
operator.
What does 'is' operator do in Python?
You missed that is not
is an operator too.
Without is
, the regular not
operator returns a boolean:
>>> not None
True
not None
is thus the inverse boolean 'value' of None
. In a boolean context None
is false:
>>> bool(None)
False
so not None
is boolean True
.
Both None
and True
are objects too, and both have a memory address (the value id()
returns for the CPython implementation of Python):
>>> id(True)
4440103488
>>> id(not None)
4440103488
>>> id(None)
4440184448
is
tests if two references are pointing to the same object; if something is the same object, it'll have the same id()
as well. is
returns a boolean value, True
or False
.
is not
is the inverse of the is
operator. It is the equivalent of not (op1 is op2)
, in one operator. It should not be read as op1 is (not op2)
here:
>>> 1 is not None # is 1 a different object from None?
True
>>> 1 is (not None) # is 1 the same object as True?
False
Related Topics
Android: How to Overlay a Bitmap and Draw Over a Bitmap
Android - Drawable with Rounded Corners at the Top Only
Android: Scrolling an Imageview
Android Webview Style Background-Color:Transparent Ignored on Android 2.2
How to Determine If Network Type Is 2G, 3G or 4G
How to Create a Transparent Demo Screen for an Android App
Measuring Text Height to Be Drawn on Canvas ( Android )
Alert Dialog from Android Service
Noclassdeffounderror When Googleanalyticstracker.Getinstance()
Java.Lang.Noclassdeffounderror: Javax.Activation.Datahandler in Android
Android Studio:How to Uninstall APK (Or Execute Adb Command) Automatically Before Run or Debug
How to Fix "Unexpected Element <Queries> Found in <Manifest>" Error
Show Timepicker with Minutes Intervals in Android
Navigation Drawer: How to Set the Selected Item at Startup
Full Webpage and Disabled Zoom Viewport Meta Tag for All Mobile Browsers