syntax

if question

hi , i have little problem with if { string nom; string ou; nom = "1"; if (nom == "1") { nom +=1; ou = nom; } Console.Write(ou); } but i cant print ou value i dont know why ...

javascript syntax: function calls and using parenthesis

why does this work.. <script type="text/javascript"> <!-- function myAlert(){ alert('magic!!!'); } if(document.addEventListener){ myForm.addEventListener('submit',myAlert,false); }else{ myForm.attachEvent('onsubmit',myAlert); } // --> </script> but not this ???? <script type="text/javascript"> <!-- function ...

C# binary literals

Is there a way to write binary literals in C#, like prefixing hexadecimal with 0x? 0b doesn't work. If not, what is an easy way to do it? Some kind of string conversion? ...

What is the difference between require and include with php?

I want to know when I should use include or require and what's the advantage of each one. Thanks! ...

How do I convert a float to an int in Javascript?

I'd like to convert a float to an int in Javascript. Actually, I'd like to know how to do BOTH of the standard convertions: by truncating and by rounding. And efficiently, not via converting to a string and parsing. ...

Ruby headscratcher - instance variable isn't outputted

I'm probably doing something stupid but I can't figure out what it is. The output I'm seeing from this program is foo test What I'm expecting to see is foo abc test Does anyone see anything obviously wrong here? class Foo def initialize(l) @label = l end def label @label end def abc @abc en...

Missing the 'with' keyword in C#

I was looking at the online help for the Infragistics control library today and saw some VB code that used the With keyword to set multiple properties on a tab control. It's been nearly 10 years since I've done any VB programming, and I had all but forgotten that this keyword even existed. Since I'm still relatively new to C#, I quickl...

What does it mean to pre-increment $#array?

I've come across the following line of code. It has issues: it is intended to do the same as push it ought to have used push it's hard to read, understand I've since changed it to use push it does something I thought was illegal, but clearly isn't here it is: $array [++$#array] = 'data'; My question is: what does it mean to pre-i...

Using for...else in Python generator expressions

I'm a big fan of Python's for...else syntax - it's surprising how often it's applicable, and how effectively it can simplify code. However, I've not figured out a nice way to use it in a generator expression, for example: def iterate(i): for value in i: yield value else: print 'i is empty' In the above example...

SQL Base32 Conversion

I am writing a SQL Function that will take in a decimal and return the base32 representation of that decimal. My problem is with the decimal to ascii conversion. I am allowed to run the following query and return an ascii character "SELECT CHAR( 65 )" which returns "A" However in my function when I am trying to build my output strin...

Ruby => operator

Where can I find an explanation of what the "=>" operator means in Ruby? Let me give more detail. If you have this: class Acct < ActiveRecord::Base validates_confirmation_of :password, :email_address, :on => :create end What is the '=>' operator doing in this case? Thanks ...

[Python] Is there anything that cannot appear inside parentheses?

I was intrigued by this answer to my question about getting vim to highlight unmatched brackets in python code. Specifically, I'm talking about the second part of his answer where he mentions that the C syntax highlighting is actually flagging as an error any instance of curly braces inside parens. It is an unobtrusive cue that you hav...

Why can't I put a delegate in an interface?

Why can't I add a delegate to my interface? ...

F# syntactic sugar

F# clearly contains a lot of things that are syntactic sugar, and as I try to learn it--without the aid of a book--I am overwhelmed by the sheer variety of syntax. Is there a simpler "core" language hidden behind all that syntactic sugar? Is there a cheat sheet list of the syntactic sugars and how they map to the core language? And hey,...

What's the difference between these two F# sequences?

> seq { for i in 0..3 do yield float i };; val it : seq<float> = seq [0.0; 1.0; 2.0; 3.0] > seq [ for i in 0..3 do yield float i ];; val it : seq<float> = [0.0; 1.0; 2.0; 3.0] P.S. why did F# originally expect sequences without the "seq" prefix, but now they want the prefix? ...

Should I assume two-elements enums will remain this way?

It happens quite a lot that I've a two member enum : enum E{ A, B } Let's say I want to assign a different value to i according to my enum value. should I write this : int i= (e== E.A)?0:1; or this : int i; if (e==E.A) i=0; else if (e==E.B) ...

Defining a class within a namespace

Is there a more succinct way to define a class in a namespace than this: namespace ns { class A {}; } I was hoping something like class ns::A {}; would work, but alas not. ...

Regex Question: Get Filename Without Extension in One Shot?In

I want to get just the filename using regex, so I've been trying simple things like ([^\.]*) which of course work only if the filename has one extension. But if it is adfadsfads.blah.txt I just want adfadsfads.blah. How can I do this with regex? In regards to David's question, 'why would you use regex' for this, the answer is, 'for f...

PHP syntax checking?

I'm using TextWrangler to edit PHP code. I often run into the problem that the code just displays as a blank page in my development environment. Is there a good way to further target which place I should look in my code for the problem? Right now I'm just manually running through every line any time I run into this, but I'm guessing...

What does "() =>" mean in C#?

Came across the following line in the Composite Application Guidelines. I know the => is a lambda but what does the () mean? What are some other examples of this? What is it called so I can search for it? this.regionViewRegistry.RegisterViewWithRegion(RegionNames.SelectionRegion , () => this.container.Resolve<EmployeesListPre...