operators

Conversion constructor vs. conversion operator: precedence

Reading some questions here on SO about conversion operators and constructors got me thinking about the interaction between them, namely when there is an 'ambiguous' call. Consider the following code: class A; class B { public: B(){} B(const A&) //conversion constructor { cout << "cal...

Is there a way to get a Curried form of the binary operators in SML/NJ?

For example, instead of - op =; val it = fn : ''a * ''a -> bool I would rather have - op =; val it = fn : ''a -> ''a -> bool for use in val x = getX() val l = getList() val l' = if List.exists ((op =) x) l then l else x::l Obviously I can do this on my own, for example, val l' = if List.exists (fn y => x = y) l then l else x::l...

What does the operator ||= stands for in ruby?

It's hard to search this in google because it consists of symbol? What does ||= stand for? And how does it work? Thanks. ...

Why use ++i instead of i++ in cases where the value is not used anywhere else in the statement?

I'm well aware that in C++ int someValue = i++; array[i++] = otherValue; has different effect compared to int someValue = ++i; array[++i] = otherValue; but every once in a while I see statements with prefix increment in for-loops or just by their own: for( int i = 0; i < count; ++i ) { //do stuff } or for( int i = 0; i < ...

Why is sizeof an operator?

Why is sizeof considered an operator and not a function? What property is necessary for something to qualify as operator? ...

What does the "|" in "int style = SWT.APPLICATION_MODAL | SWT.OK;" do (and how to Google it)?

I can't search for | in Google. If you had found it in a software source code that you are trying to interpret, you didn't know what it does and you couldn't ask other people for help, how would you find out what it does? ...

What does the !! operator (double exclamation point) mean in JavaScript?

I've just walked into this code: val.enabled = !!enable and have no idea what does "!!" do... I googled JavaScript operators but haven't found this one. ...

howto get defined operators for a type in .net

I'm trying to get the list of defined operators for a specific type in order to see what kind of operations can be applied to that type. For example, the type Guid supports operations == and !=. So if user wants to apply <= operation for a Guid type i can handle this situation before an exception occurs. Or if i could have the list ...

c# 3.0 Meaning of expression ()=>

What is the meaning of this expression " () =>". I have seen it used in a constructor: return new MyItem(itemId, () => MyFunction(myParam)); Thank you ...

c++ operator overload and usage

bool operator()(Iterator it1, Iterator it2) const { return (*it1 < *it2); } Can someone explain this function for me, thanks! is this means overload the operator ()? after overload this, how to use it ? ...

How to bitwise shift in VB.NET?

How do I bitwise shift right/left in VB.NET? Does it even have operators for this, or do I have to use some utility method? ...

Batch not equals

According to this, !==! is the not-equal string operator. Trying it, I get: C:\> if "asdf" !==! "fdas" echo asdf !==! was unexpected at this time. What am I doing wrong? ...

Difference between "and" and && in Ruby?

What is the difference between && and and operators in Ruby? ...

What is the function of the ~ operator?

Unfortunately, search engines have failed me using this query. For instance: int foo = ~bar; ...

Is there any wisdom behind "and", "or" operators in Ruby ?

I wonder why ruby give and, or less precedence than &&, || , and assign operator? Is there any reason? ...

What's the difference between 'eq' and '=~' in Perl?

What is the difference between these two operators? Specifically, what difference in $a will lead to different behavior between the two? $a =~ /^pattern$/ $a eq 'pattern' ...

How to optimize boolean operation?

I have two RadioButtons: r1 and r2. I have to enable both on Enabled = true and disable only unchecked on Enabled = false public bool Enabled { set { if(value) { r1.Enabled = value; // true r2.Enabled = value; } else { if(!r1.Checked) { r1.Enabled = value; // false if not checked ...

Understanding this class in python. The operator % and formatting a float.

class FormatFloat(FormatFormatStr): def __init__(self, precision=4, scale=1.): FormatFormatStr.__init__(self, '%%1.%df'%precision) self.precision = precision self.scale = scale def toval(self, x): if x is not None: x = x * self.scale return x def fromstr(self, s): ...

Java: What does ~ mean

In source code I found this line: if ((modifiers & ~KeyEvent.SHIFT_MASK) != 0) .... Does somebody know what the ~ means? Thanks ...

Python: Behaviour of increment and decrement operators

I am a newbie to Python. I notice that a pre-increment/decrement operator can be applied on a variable (like ++count). It compiles, but it does not actually change the value of the variable! What is the behavior of the pre-increment/decrement operators (++/--) in Python? Why does Python deviate from the behavior of these operators seen ...