syntax

if parentViewContoller statement

I'm writing a program with a UITableView with and add button in the Navigation Bar which leads to an edit page. When you click on an item in the table, a view (rView) is pushed with information pertaining to that item. This view has an edit button that also leads to the edit page. Is there a way that I could put an if statement for the ...

Simple C# "new" question - syntax related

Hi, I am just curious how to create new object in the command. (in order to save space and learn it of course). Just to combine the commands together and do not have picturebox abc= new picturebox on the extra line, Like this: this.Form.Controls.Add(new Picturebox abc) //something like that? Thanks for help ...

C#: Typing variables holding instances of constrained generic classes

I am just starting to get to grips with generics and am (ab)using them to refactor a fairly complex section of my code (I've only been using c# for a little while but am fairly experienced in other languages). I have an inheritance structure where my classes extend a base class. In the base class I have most of the functionality impleme...

Strange syntax of Number methods in JavaScript

Take a look at the following code: Number.prototype.isIn = function () { for (var i = 0, j = arguments.length; i < j; ++i) { if (parseInt(this, 10) === arguments[i]) { return true; } } return false; }; var x = 2; console.log(x.isIn(1,2,3,4,5)); // <= 'true' console.log(2.isIn(1,2,3,4,5)); // <= Error: 'missing ) afte...

More simple math help in bash!

In the same thread as this question, I am giving this another shot and ask SO to help address how I should take care of this problem. I'm writing a bash script which needs to perform the following: I have a circle in x and y with radius r. I specify resolution which is the distance between points I'm checking. I need to loop over x and...

What's wrong with this $(this).attr("id").toggle("");

What is the proper syntax for toggling the this.id object $(this).attr("id").toggle(""); Thanks. Google is surprisingly not helping :( ...

Why a full stop, "." and not a plus symbol, "+", for string concatenation in PHP?

Why did the designers of PHP decide to use a full stop / period / "." as the string concatenation operator rather than the more usual plus symbol "+" ? Is there any advantage to it, or any reason at all? Or did they just like to? :o) ...

Conditional statement operands order

Often I stumble upon following approach of defining conditional statement: if(false === $expr) { ... } I have several questions about this. Is there a point of using constant value (false, 1, 0, 123, 'string' etc) as a first operand instead of second in cases when second operand is not too long. For example, I would prefer to...

Tricky makefile syntax with quotes

Hello, I have the following start on a makefile rule (thanks to help from others), but it doesn't quite work yet: test_svn_version: @if [ $$(svn --version --quiet \ perl -ne '@a=split(/\./); \ print $$a[0]*10000 + $$a[1]*100 + $$a[2]') \ -lt 10600 ]; \ then \ echo >&2 "Svn ve...

JQuery clearing an input text field

I have a question regarding clearing an input text field when a different drop down on teh same page is clicked, the value in the input text field should be cleared. Here is my jQuery ftn. The alert message is shown everytime I select an option from drop down but the field does not get cleared. Any idea what the correct syntax should be:...

Associationg vim syntax with file extension

Hi, how do I tell vim to use a certain syntax definition with a new file extension ? Let's say I have files that are some kind of xml, but have a different extension, how do I let vim know that it should use syntax=xml by default for that new type ? Any help appreciated. ...

Simple ajax not working, probably syntax error.

window.onload = function(){ testAjax(); } var testAjax = function(){ var request = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); request.onreadystatechange = function(){ if (request.readyState == 4){ // Server is done try{ var p = document.getElementById['a']...

What does the leading semicolon in JavaScript libraries do?

In several JavaScript libraries I saw this notation at the very beginning: /** * Library XYZ */ ;(function () { // ... and so on While I'm perfectly comfortable with the "immediately executed function" syntax (function(){...})() I was wondering what the leading semicolon is for. All I could come up with is, that it is an insura...

Why doesn't Perl allow one liners to be 'unblocked'?

for example: if (something) function(); else nope(); ...

Why do Perl control statements require braces?

This may look like the recent question that asked why Perl doesn't allow one-liners to be "unblocked," but I found the answers to that question unsatisfactory because they either referred to the syntax documentation that says that braces are required, which I think is just begging the question, or ignored the question and simply gave bra...

Why this fails in PHP?

echo explode(' ','A B')[0] What's the right version? ...

What is %2 in $id%2

What does %2 do in the following php? $id=(int)@$_REQUEST['id']; echo ( !($id%2) )? "{'id':$id,'success':1}": "{'id':$id,'success':0,'error':'Could not delete subscriber'}"; ...

C# sample syntax question

Please, help me with to understand this piece of code: protected Customer() { } in the following class (Model class from sample WPF MVVM app): public class Customer : IDataErrorInfo { #region Creation public static Customer CreateNewCustomer() { return new Customer(); } public static C...

C# Attaching Eventhandler with New Handler vs Directly assigning it

Hello, I was just wondering what the actual difference, advantage and disadvantages of creating a new event handler, vs assigning it directly to the event ? _gMonitor.CollectionChanged += new NotifyCollectionChangedEventHandler(OnCollectionChanged); vs _gMonitor.CollectionChanged += OnCollectionChanged; Thanks, Raul ...

Java - string declaration occupying multiple lines?

I am using Java. Inside a Java program I am writing a SQL query: string query = "select * from tableA" ; However sometimes the query is really large. In those cases I want to write the query in different lines e.g.: string query = "select blah1, blah2 blah3, blah4 blah5, blah6 ...