What Does ? ...:... Do

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 ! 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 \ do in python?

It separates lines, in PEP8 the maximum length of a line is 79 characters.

print('Hello world!')

is the same as:

print \
('Hello world!')

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 '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

What does !-- do in JavaScript?

! inverts a value, and gives you the opposite boolean:

!true == false
!false == true
!1 == false
!0 == true

--[value] subtracts one (1) from a number, and then returns that number to be worked with:

var a = 1, b = 2;
--a == 0
--b == 1

So, !--pending subtracts one from pending, and then returns the opposite of its truthy/falsy value (whether or not it's 0).

pending = 2; !--pending == false 
pending = 1; !--pending == true
pending = 0; !--pending == false

And yes, follow the ProTip. This may be a common idiom in other programming languages, but for most declarative JavaScript programming this looks quite alien.

math in java - what does % do?

% is the Modulus operator. For Java Modulus:

"%  Modulus - Divides left hand operand by right hand operand and returns remainder"

For example: 10 % 3 is equal to 1. To visually see this -

10 % 3
10 - 3 = 7 // Start by subtracting the right hand side of the % operator
7 - 3 = 4 // Continue subtraction on remainders
4 - 3 = 1
Now you can't subtract 3 from 4 without going negative so you stop.
You have 1 leftover as a remainder so that is your answer.

You can think of it as "How much would I have to subtract to the value on the left in order to make it evenly divisible by the right hand value?"


And yes, actually it's the same symbol in C++ for modulus.


"In arithmetic, the remainder is the integer "left over" after dividing one integer by another to produce an integer quotient (integer division)."

"In computing, the modulo (sometimes called modulus) operation finds the remainder of division of one number by another."

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 ?. syntax is a new feature in C#6 and is a short cut for checking that the variable isn't null before deferencing it. The fact that you're getting that error on the build server shows that the build server is still running an older version of the compiler.

If you can, get the build agent machine upgraded to use the same version of C# and .NET that you're using to develop with.

If you can't get the build agent upgraded to use the latest version of C# (and .NET) then you'll have to go back to the old way of checking for null:

ItemSupplierName = u != null ? u.SupplierName : null

What does ?. do in Dart?

It's a null safe operator.

Use ?. when you want to call a method/getter on an object IF that
object is not null (otherwise, return null).

_drawerKey.currentState?.open();

Call open() only if it's not null.

More info: https://medium.com/@thinkdigitalsoftware/null-aware-operators-in-dart-53ffb8ae80bb



Related Topics



Leave a reply



Submit