operators

Using <<<CON in PHP

What is the effect of the following code: $page = <<<CON <p><center>Blah blah blah</center></p> CON; What does the <<<CON do? ...

'\' operator does not support floats?

Dim x As Integer = 1.8 \ 1 Error: Option Strict On disallows implicit conversions from 'Double' to 'Long' What Long?? EDIT: Apparently Visual Basic attempts to convert any floating-point numeric expression to Long. OK, this part is clear. Now, I can use the CType((Math.Round(myResultingSingle)), Integer) but what for ...

Whats the name of this operator "+=" ?

Whats the name of this operator "+=" ? ...

Double Not (!!) Operator in PHP

Hi guys, does anybody know what the double not operator does in PHP ex: return !! $row; What would the code above do? Thanks ...

if($ext == ('zip' || 'png')) { echo "Is it possible ?" }

Hi all :) I'm currently writing sort of a download manager and I was asking myself if that was possible: if($ext == ('zip' || 'png')) { echo "Is it possible ?" } It returns true everytime, so I guess it's not possible. But do you have an idea about how I could easily do this ? I mean, not with plenty of "if" or "switch"... Thanks an...

Using string constants in implicit conversion

Consider the following code: public class TextType { public TextType(String text) { underlyingString = text; } public static implicit operator String(TextType text) { return text.underlyingString; } private String underlyingString; } TextType text = new TextType("Something"); String str = text; //...

What does << mean in java?

Hi, I can't find out what << means in java, because I can't search for it on Google I am absolutely lost! The code in question is: public int getRGB() { return ((red << 16) | (green << 8) | blue); } taken from http://java.sun.com/docs/books/tutorial/essential/concurrency/example/ImmutableRGB.java Would really appreciate someone ...

Java operator precedence guidelines

Misunderstanding Java operator precedence is a source of frequently asked questions and subtle errors. I was intrigued to learn that even the Java Language Specification says, "It is recommended that code not rely crucially on this specification." JLS §15.7 Preferring clear to clever, are there any useful guidelines in this area? Here a...

Operator== in derived class never gets called.

Can someone please put me out of my misery with this? I'm trying to figure out why a derived operator== never gets called in a loop. To simplify the example, here's my Base and Derived class: class Base { // ... snipped bool operator==( const Base& other ) const { return name_ == other.name_; } }; class Derived : public Base { // ......

Is Perl's flip-flop operator bugged? It has global state, how can I reset it?

I'm dismayed. Ok, so this was probably the most fun perl bug I've ever found. Even today I'm learning new stuff about perl. Essentially, the flip-flop operator .. which returns false until the left-hand-side returns true, and then true until the right-hand-side returns false keep global state (or that is what I assume.) My question is c...

Why is "operator bool()" invoked when I cast to "long"?

I have the following class: class MyClass { public: MyClass( char* what ) : controlled( what ) {} ~MyClass() { delete[] controlled; } operator char*() const { return controlled; } operator void*() const { return controlled; } operator bool() const { return controlled != 0; } private: char* controlled; }; This is com...

So you think you know the priority of operators in c++?

I just ran into a piece of code that not only compiles, but gives the expected result (where x is an integer value): int y = (int)(0.5 * x * x + + + 0.6 * x + 1.2); It took me a while to figure out what happens and I must say it was an interesting operator problem. Without compiling the program, what are the results of the following o...

Two '==' equality operators in same 'if' condition are not working as intended.

I am trying to establish equality of three equal variables, but the following code is not printing the obvious true answer which it should print. Can someone explain, how the compiler is parsing the given if condition internally? #include<stdio.h> int main() { int i = 123, j = 123, k = 123; if ( i == j == k) ...

C#: bitwise operator in enum (Custom Authorization in MVC)

I'm currently reading an article , but I do not really understand how this work with the logical operator. Can anyone explain this to me? eg. If I want to have 4 level securities with customer, employee, supervisor and Admin. [Serializable] [Flags] public enum WebRoles { customer= 1 << 0, employee= 1 << 1, sup...

What does !! (double exclamation point) mean?

In the code below, from a blog post by Alias, I noticed the use of the double exclamation point !!. I was wondering what it meant and where I could go in the future to find explanations for Perl syntax like this. (Yes, I already searched for '!!' at perlsyn). package Foo; use vars qw{$DEBUG}; BEGIN { $DEBUG = 0 unless defined $DEBU...

When do you overload operator new?

Possible Duplicate: Any reason to overload global new and delete? In what cases does it make perfect sense to overload operator new? I heard you do it in a class that is very often allocated using new. Can you give an example? And are there other cases where you would want to overload operator new? Update: Thanks for all ...

How to use the double not (!!) operator in javascript

I understand what the double not operator does in javascript. I'm curious about it's use though and whether or not a recent assertion that I made is correct. I said that if (!!someVar) is never meaningful nor is (!!someVar && ... because both the if and the && will cause someVar to be evaluated as a boolean so the !! is superfluous. In...

Ruby ternary operator without else.

Is there a ruby idiom for "If do-this," and "do-this" just as a simple command? for example, I'm currently doing object.method? a.action : nil to leave the else clause empty, but I feel like there's probably a more idiomatic way of doing this that doesn't involve having to specify a nil at the end. (and alternatively, I feel like ta...

How to auto answer expression composed of operator and operand

Sorry about the vague question. I'll try to explain better. I have condition objects composed of a string parameter, a string operator and a value. for example: {"Age", ">","33"}. Now, I have a hashtable where the key is the parameter name and the value is the actual parameter value. {"Height" ,"166"} I would like to go over the condi...

Why can't I access this struct through its pointer?

#include <stdio.h> #include <stdlib.h> typedef int element; struct cell { element e; struct cell *p; }; typedef struct cell* CELL; int main() { CELL* p; p = (CELL*) malloc (sizeof(struct cell)); p->e = 8; /* This ain't working */ *p.e = 8; /* This doesn't help anything either */ return 0; } I...