syntax

Understanding Ruby Syntax

Possible Duplicates: What is the best way to learn Ruby? Explain Iterator Syntax on Ruby on Rails I'm still learning ruby, ruby on rails and such. I'm getting better at understanding all the ruby and rails syntax but this one has me a little stumped. respond_to do |format| format.html # index.html.erb format.xml { rend...

Where are literals stored in statement like this if( var == 'x')?

Say in a statement like this char var; if( var == 'x'); Do we allocate any memory for 'x' at first place? If yes, which is it (stack/data)? Thanks! ...

Why does a collection initializer expression require IEnumerable to be implemented?

Why does this generate a compiler error: class X { public void Add(string str) { Console.WriteLine(str); } } static class Program { static void Main() { // error CS1922: Cannot initialize type 'X' with a collection initializer // because it does not implement 'System.Collections.IEnumerable' var x = new ...

.NET: Is "foreach" command?

Hello, I have just a terminology question. I have read that if, foreach etc. are statements but what does it mean in the terminology - are these commands? It is maybe "lost in the translation" problem ...

Using Statement with Generics: using ISet<> = System.Collections.Generic.ISet<>

Since I am using two different generic collection namespaces (System.Collections.Generic and Iesi.Collections.Generic), I have conflicts. In other parts of the project, I am using both the nunit and mstest framework, but qualify that when I call Assert I want to use the nunit version by using Assert = NUnit.Framework.Assert; Which w...

Rails query with attributes on two tables

How do I write a find(:all) query in rails (v2.3.5) that has parameters both in the model I am running the 'find' on, and in another table? e.g. I am trying to search for 'posts' by 'author' and 'tag'. Author is an attribute of post, whereas tag is associated with it through another table. I can get the tags by including ':joins =...

MySQL JOIN table query help

Hello, I hate asking for code but I just can't seem to do the below - Staff | lastname - name - position | | Henderson | John | A | | Howard | Bob | B | | Hendry | Chris | B | Max_person | lastname - change | | Henderson | 0.9 | | Howard | 0.2 | | Hendry ...

Why do you need the + between variables in javascript?

Why does this line work $('#body-image').css("background-image", 'url('+ backgroundimage +')'); but not this one $('#body-image').css("background-image", 'url('backgroundimage')'); or this one $('#body-image').css("background-image", 'url(backgroundimage)'); ...

Regular expression for a hostname

I'm trying to match a hostname similar to foo-bar3-vm.companyname.local. The part that is foo-bar3 can be any combination of letters, numbers, and hyphens, but I want to ensure it ends in -vm.companyname.local. I was attempting to use /^[a-zA-Z0-9\-]*[vmVM]*\.companynanme\.local$/, but that seems to match anything ending in .companynam...

Help with C scanf syntax

When I run the following snippet it runs until the second question. It then puts the "Is the customer a student? (y/n) \n" and "What is the movies time? (in hours) \n" prompts together (no area to answer between them). If one takes any action from there on, the program stops working. What did I do wrong? (i'm pretty sure it's syntax rela...

Chrome Developer Console Can't Run JS Loops

In the chrome console, I can't run any loops. Why is this? For example, the following will give a syntax error of "Expected '('" for each (var item in [1, 2, 3]) alert(item) ...

Unexpected Scala pattern matching syntax

I had a List of Scala tuples like the following: val l = List((1,2),(2,3),(3,4)) and I wanted to map it in a list of Int where each item is the sum of the Ints in a the corresponding tuple. I also didn't want to use to use the x._1 notation so I solved the problem with a pattern matching like this def addTuple(t: (Int, Int)) : Int = ...

sql join syntax

I'm kind of new to writing sql and I have a question about joins. Here's an example select: select bb.name from big_box bb, middle_box mb, little_box lb where lb.color = 'green' and lb.parent_box = mb and mb.parent_box = bb; So let's say that I'm looking for the names of all the big boxes that have nested somewhere inside them a litt...

When to use * and ** as a function argument in python function

When can I pass * and ** in the argument of a Python function? i.e.: def fun_name(arg1, *arg2 , ** arg3): ...

Erlang: What does question mark syntax mean?

What does the question mark in Erlang syntax mean? For example: Json = ?record_to_json(artist, Artist). The full context of the source can be found here. ...

pythonic way to rewrite an assignment in an if statement

Is there a pythonic preferred way to do this that I would do in C++: for s in str: if r = regex.match(s): print r.groups() I really like that syntax, imo it's a lot cleaner than having temporary variables everywhere. The only other way that's not overly complex is for s in str: r = regex.match(s) if r: p...

C# order of function modifiers

Hi, I would like to know if there is a standard to set the order of function modifiers in C#. i.e. public static void AssignTo(this int me, int value) {} static public void AssignTo(this int me, int value) {} this both work well, BUT when I code: public void static AssignTo(this int me, int value) {} I receive the following err...

C# order of function modifiers

Possible Duplicate: C# order of function modifiers Hi, I would like to know if there is a standard to set the order of function modifiers in C#. i.e. public static void AssignTo(this int me, int value) {} static public void AssignTo(this int me, int value) {} this both work well, BUT when I code: public void static Ass...

Why does adding a trailing comma after a string make it a tuple?

I want to know that why adding a trailing comma after a string makes it tuple. I.e. abc = 'mystring', print abc # ('mystring,) When I print abc it returns a tuple like ('mystring',). ...

What's the reason of using ; in F# lists instead of ,?

This might be a strange question but if I want to define a list of integers from: 1, 2, 3, 4, 5, 6, 7, 8, 9 Do I need to do it using the ; character? [ 1; 2; 3; 4; 5; 6; 7; 8; 9 ] instead of?: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] It just seems to me , is more natural and easy on the eyes. Just wondering the idea behind using ;? (Not cr...