Showing posts with label syntax. Show all posts
Showing posts with label syntax. Show all posts

Thursday, May 24, 2012

Wednesday, May 16, 2012

New/strange Java 'try()' syntax?


While messing around with the custom formatting options in Eclipse, in one of the sample pieces of code, I saw code as follows:

Monday, May 7, 2012

What is the performance difference, if any, between if(!foo) and if(foo == false) in Java?


Logically, if(!foo) and if(foo == false) are equivalent. How are they represented in Java? Is there any difference between the two after compilation, either in the bytecode or in performance? I was unable to find an answer in the JLS, and searching brought up a lot of results about = vs. == typos and ==/equals() behavior. (In this case, the symbols hampered my searching; for future searchers, negation operator, equals false, equal to false, not condition).

Friday, May 4, 2012

Anonymous recursive PHP functions


Is it possible to have a PHP function that is both recursive and anonymous? This is my attempt to get it to work, but it doesn't pass in the function name.

Sunday, April 8, 2012

var x, y = "foo"; Can this be accomplished?



Since it is possible to do:







var x = 'foo', y = 'foo';







Would this also be possible?







var x, y = 'foo';







I tried it, however x becomes undefined.





I know this may seem like a silly or redundant question, but if I'm curious about something, why not ask? Also you will probably wonder why I would need two variables equal to the same thing in scope . That is not the point of the question. I'm just curious.



Source: Tips4all

What does | in this code mean?





function foo() {}

var bar = foo <| function() {};







This is the first time I've seen something like this. What does <| mean?





Source: https://github.com/allenwb/ESnext-experiments/blob/master/ST80collections-exp1.js



Source: Tips4all

Sunday, January 29, 2012

PHP if else - proper use of "else&rdquo;


A professor told me long ago to use else when "chaining" multiple conditions in a series (I was still learning). Now that I've been tinkering with several frameworks and CMS years later, I find it quite amusing that what I was taught to do isn't necessarily so.

Monday, January 16, 2012

Thursday, January 12, 2012

Set variable within another context


I have the following function




"use strict";
function Player
{
this.width;
this.height;
this.framesA = 5;

this.image = new Image();
this.image.onload = function ()
{
width = this.width;
height = this.height / framesA;
}
this.image.src = "Images/angel.png";
}