Questions tagged [operators]
Operators are symbols that occur in nearly all programming and coding languages, used for performing calculations, comparisons, and assignments of data. Use this tag for any questions relating to operators, in any language, including things such as syntax, behaviour and use.
operators
1,326
questions
2470
votes
10
answers
1.0m
views
What are the basic rules and idioms for operator overloading?
Note: This question and the original answers are from 2010 and partially outdated. Most of it is still good and helpful, but the original text no longer covers everything there is to know about C++ ...
5109
votes
25
answers
838k
views
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
What is this?
This is a collection of questions that come up now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.
This ...
5645
votes
47
answers
2.2m
views
Which equals operator (== vs ===) should be used in JavaScript comparisons?
I'm using JSLint to go through JavaScript, and it's returning many suggestions to replace == (two equals signs) with === (three equals signs) when doing things like comparing idSele_UNVEHtype.value....
161
votes
5
answers
50k
views
The 3 different equals
What is the difference between =, ==, and ===?
I think using one equal sign is to declare a variable while two equal signs are for a comparison condition and lastly three equal signs are for ...
7956
votes
31
answers
2.9m
views
Does Python have a ternary conditional operator?
Is there a ternary conditional operator in Python?
616
votes
11
answers
109k
views
"is" operator behaves unexpectedly with integers
Why does the following behave unexpectedly in Python?
>>> a = 256
>>> b = 256
>>> a is b
True # This is an expected result
>>> a = 257
>>> b = ...
4170
votes
36
answers
946k
views
What is the !! (not not) operator in JavaScript?
I saw this code:
this.vertical = vertical !== undefined ? !!vertical : this.vertical;
It seems to be using !! as an operator, which I don't recognize. What does it do?
218
votes
9
answers
60k
views
What does the comma operator , do?
What does the , operator do in C?
578
votes
13
answers
388k
views
How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?
What is the difference between == and ===?
How exactly does the loosely == comparison work?
How exactly does the strict === comparison work?
What would be some useful examples?
1553
votes
11
answers
894k
views
What are bitwise shift (bit-shift) operators and how do they work?
I've been attempting to learn C in my spare time, and other languages (C#, Java, etc.) have the same concept (and often the same operators)...
At a core level, what does bit-shifting (<<, >&...
10169
votes
26
answers
1.0m
views
What is the '-->' operator in C/C++?
After reading Hidden Features and Dark Corners of C++/STL on comp.lang.c++.moderated, I was completely surprised that the following snippet compiled and worked in both Visual Studio 2008 and G++ 4.4. ...
149
votes
8
answers
24k
views
How do "and" and "or" act with non-boolean values?
I'm trying to learn python and came across some code that is nice and short but doesn't totally make sense
the context was:
def fn(*args):
return len(args) and max(args)-min(args)
I get what it'...
3856
votes
11
answers
318k
views
Why don't Java's +=, -=, *=, /= compound assignment operators require casting?
Until today, I thought that for example:
i += j;
Was just a shortcut for:
i = i + j;
But if we try this:
int i = 5;
long j = 8;
Then i = i + j; will not compile but i += j; will compile fine.
...
586
votes
16
answers
731k
views
What is the difference between '/' and '//' when used for division?
Is there a benefit to using one over the other? In Python 2, they both seem to return the same results:
>>> 6/3
2
>>> 6//3
2
556
votes
17
answers
157k
views
What does map(&:name) mean in Ruby?
I found this code in a RailsCast:
def tag_names
@tag_names || tags.map(&:name).join(' ')
end
What does the (&:name) in map(&:name) mean?