I want to toggle a variable between 0 and 1. If it's 0 I want to set it to 1, else if it's 1 I want to set it to 0.
Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Wednesday, May 30, 2012
Is there a better way of writing v = (v == 0 ? 1 : 0);
Friday, May 18, 2012
isset() vs strlen() - a fast/clear string length calculation
I came across this code...
if(isset($string[255])) {
// too long
}
Friday, April 6, 2012
"AND" vs "&&" as operator
Actually, I am facing a codebase where developpers decided to use ' AND ' and ' OR ' instead of ' && ' and ' || '. I know that there is difference in operators precedence ( && goes before ' and '), but with given framework (prestashop to be precise) is clearly not a reason. So, my question: which version are you using? Is ' and ' more readable than ' && '? || there is ~ difference?
PHP return(value); vs return value;
Is there any difference between return($var); and return $var; other then wrapping it in parentheses?
Thursday, March 8, 2012
Prefixing property names with an underscore in Objective C
I've always avoided underscores in my variable names, perhaps because its just not what was done back in my learning Java in college days. So when I define a property in Objective C this is what I naturally do.
Sunday, January 29, 2012
PHP if else - proper use of "else”
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.