I'm cleaning up Java code for someone who starts their functions by declaring all variables up top, and initializing them to null/0/whatever, as opposed to declaring them as they're needed later on.
What are the specific guidelines for this? Are there optimization reasons for one way or the other, or is one way just good practice? Are t...
Just curious how is the .NET 4.0 CLR world going to call methods ending in question marks and exclamations? What will the syntax look like calling from C# or VB.NET?
...
This is a really simple question and I'm suprised I have to ask it but...
How does one declare a readonly local variable in VB.Net?
Java and C++ have final/const local variables so I'm sure VB.Net must have them, but I just can't find the syntax for it.
...
Hello,
I have the following code snippet:
// Notify the source (the other control).
if (operation != DropOperation.Reorder) {
e = new DroppedEventArgs()
{
Operation = operation == DropOperation.MoveToHere ? DropOperation.MoveFromHere : DropOperation.CopyFromHere,
Source = src,
Target = this,
DroppedItems = src...
I missed a "=",
should be:
if(maxi - 1 == i)...
but firebug didn't report anything.
And it took quite a while for me to found it.
Is it a bug of firebug?
...
PHP:
$a = "0";
$b = "00";
var_dump(empty($a)); # True (wtf?)
var_dump($a == $b); # True... WTF???
var_dump(empty($b)); # False WWWTTTFFFF!!??
I've read the docs. But the docs don't give explanation as to why they designed it this way. I'm not looking for workarounds (I already know them), I'm looking for an explanation.
Why is it lik...
Hi,
I'm writing some code that looks like this:
while(true) {
switch(msg->state) {
case MSGTYPE: // ...
break;
// ... more stuff ...
case DONE:
break; // **HERE, I want to break out of the loop itself**
}
}
Is there any direct way to do that?
I know I can use a flag, and break from the loop by pu...
Can anybody explain how this line works?
return $y < 0 ? - pip2 : pip2 if $x == 0;
if $y <0 it returns -pip2, but what it returns when $y >= 0 and $x != 0 ?
This line is from this function:
sub _atan {
my( $y, $x ) = @_;
return $y < 0 ? - pip2 : pip2 if $x == 0;
return atan( $y / $x );
}
...
What is the syntax for indexOf() to go through a multidimensional array?
For instance:
var x = [];
// do something
x.push([a,b]);
x.indexOf(a) // ??
I want to find 'a' and do something with 'b'. But it does not work... As this method should be iterative itself, I do not presume using any other iteration would be a good thing to do. C...
What does this piece of code in C do:
p = (1, 2.1);
What do we know about p?
...
I am trying to check each index in an 8 digit binary string. If it is '0' then it is 'OFF' otherwise its 'ON'. I'm wondering if there's a more concise way to write this code with a switch-like feature.
Thanks,
...
Running:
Apache 2.2.3
Ruby 1.8.7
Rails 2.3.4
Passenger 2.2.5
Error message:
/var/www/derscheidfamily/app/controllers/greetings_controller.rb:14: syntax error, unexpected '/', expecting '\n' or ';'
def app/controllers
^
/var/www/derscheidfamily/app/controllers/greetings_controller.rb:20: syntax error, unexpected '/', expecti...
I was wondering if there exists somewhere a collection or list of C# syntax shortcuts. Things as simple omitting the curly braces on if statements all the way up to things like the ?? coalesce operator.
...
I'm translating a JavaScript algorithm into PHP, and I ran into the symbol >>, and I have no clue what it means. It's hard to search Google for symbols, so can anyone tell me what it means?
...
Can anyone recommend how to install and use wordpress.org GeSHi syntaxhighlighter? I'm looking for start-to-end directions in one place, not a link that refers to info in 8 other "prerequesite" knowledge links.
...
My understanding of the different kinds of JavaScript functions are as follows:
function MyObj() {
this.propOne = true;
this.publicInstanceFunc = function() {
if (propOne)
return 'public instance function';
}
function privateFunc() {
return 'private function only visible inside this constructo...
I have gotten the following to work:
for i in {2..10}
do
echo "output: $i"
done
It produces a bunch of lines of output: 2, output: 3, so on.
However, trying to run the following:
max=10
for i in {2..$max}
do
echo "$i"
done
produces the following:
output: {2..10}
How can I get the compiler to realize it should treat $ma...
I saw this in a facebook leaked code...
$disabled_warning = ((IS_DEV_SITE || IS_QA_SITE) && is_disabled_user($user));
now unless I am reading it wrong then it is saying that (($var) can be used as a function?
...
extern int ether_hostton (__const char *__hostname, struct ether_addr *__addr)
__THROW;
I found the above function definition in /usr/include/netinet/ether.h on a Linux box.
Can someone explain what the double underscores mean in front of const (keyword), addr (identifier) and at last __THROW.
...
How do I get the current index in a foreach loop?
foreach( $arr as $key=>$val)
{
//how to get index?
//how to get first element in an associated array
}
...