syntax

C if condition not working as expected

All, I come from java and php world so this maybe a factor. But I have a problem with: printf("%s\n",data[0]); if(data[0] == "BG01") { printf("%s\n",otherstring); } The problem is that first printf returns in the console "BG01" but for some reason the IF condition doesn't pick up on it and the second printf never gets executed. ...

php syntax for echo javascript function

Hello, I hope somebody can help me with this little problem. The problem is that I still get confused with the syntax The php line echo's a javascript function that takes one parameter, the database value. It needs to be corrected, to get it to work. extra comma's??escaping?? I never know where exactly. while($row=mysql_fetch_array($...

Javascript language and the $ in jquery

I was wondering, how does the $. in $.ajax({...}); work? it doesnt make sense to me. Sure .ajax as a member make sense but $ isnt a variable name? or is it? How is it defined? ...

When a PHP function returns an array, can I access its elements inline?

In PHP, this code works: $usage = (package_manager_get_user_usage($uid)); $usage = $usage[email]; But this does not: $usage = (package_manager_get_user_usage($uid))[email]; Why? They appear to be doing the same thing. ...

C# dictionary initializer compilation inconsistency

The following code compiles, but fails with a NullReferenceException: class Test { public Dictionary<string, string> Dictionary { get; set; } } static void Main(string[] args) { var x = new Test { Dictionary = // fails { { "key", "value" }, { "key2", "value2" } } }; } If you repla...

Why is PHP printing my number in scientific notation, when I specified it as .000021?

In PHP I have the following code: <?PHP $var = .000021; echo $var; ?> the output is 2.1E-5 ! Why? it should print .000021 ...

What makes a language readable or not readable?

I heard people say they can understand their python code a year later but not their XYZ code. Why? I dont know what is good about python syntax or what is bad about another. I like C# but i have a feeling VB.NET code is easier to read. I am doing language design so what do you find makes code/syntax/language readable or not readable? ...

How was the syntax chosen for static methods in Python?

I've been working with Python for a while and I find the syntax for declaring methods as static to be peculiar. A regular method would be declared: def mymethod(self, params) ... return A static method is declared: def mystaticethod(params) ... return mystaticmethod = staticmethod(mystaticmethod) If you don't add the s...

multiple select in one statement

This is hard to explain but i need to - select id from customers - foreach customer find the order with that id -- foreach order (for that customer) --- select product.name, product.max on order.productId=product.id I dont know how to pull this data. I would need multiple separate selects? can i write a long single sql statement (';' ...

Does "match ... true -> foo | false -> bar" have special meaning in Ocaml?

I encountered the following construct in various places throughout Ocaml project I'm reading the code of. match something with true -> foo | false -> bar At first glance, it works like usual if statement. At second glance, it.. works like usual if statement! At third glance, I decided to ask at SO. Does this construct have spec...

How to reference a control's properties in Access

For instance, I have a query which takes as a parameter the text property of a drop-down box [DDB1] of Form1. How do I reference the property? My stumbling around google has suggested that it should be something along the lines of Forms![Form1]![DDB1].text But I have been unable to find a definitive syntax for such references. Any ide...

List of Scala's "magic" functions

Where can I find a list of scala's "magic" functions, such as apply, unapply, update, += etc? By magic-functions I mean functions which are used by some syntactic sugar of the compiler, for example o.update(x,y) <=> o(x) = y I googled for some combination of scala magic and synonyms of functions but didn't find anything. update: I th...

How to print error of python - simple question

Hi, is this possible: try: something here except: print 'the whatever error occurred.' Is it possible to do this in 1 line? Edit...I want to print the 1 line AFTER "except:" I simply just want to print the error, whatever that is. ...

Java: What does ~ mean

In source code I found this line: if ((modifiers & ~KeyEvent.SHIFT_MASK) != 0) .... Does somebody know what the ~ means? Thanks ...

EBNF for math equations and inequalities

I would like to design a math language satisfying EBNF, to let me write equation systems and inequalities as close to natural math language as possible. I would like to have two parsers for this little language, one parser prepares the equalities/inequalities written in this language for publication, another parser prepares it for comput...

Ruby: Shortest/most idiomatic way of determining whether a variable is any one of a list of values

This seems a ridiculously simple question to be asking, but what's the shortest/most idiomatic way of rewriting this in Ruby? if variable == :a or variable == :b or variable == :c or variable == :d # etc. I've previously seen this solution: if [:a, :b, :c, :d].include? variable but this isn't always functionally equivalent - I beli...

Translate goto statements to if, switch, while, break, etc.

Is there a way to mechanically translate goto statements to if, switch, while, break, and continue statements, etc, or with function calls, objects, anything? ...

Error in nested for loops (Python)

Hi, I am getting an error in the following code. The Error message is "Error: Inconsistent indentation detected!" s=[30,40,50] a=[5e6,6e6,7e6,8e6,8.5e6,9e6,10e6,12e6] p=[0.0,0.002,0.004,0.006,0.008,0.01,0.015,0.05,0.1,0.15,0.2] j=0 b=0 x=0 for j in s: h=s[j] print "here is the first loop" +h for b in a: c=a[b] ...

Is there a programming language whose declarations are similar to those used in UML?

Like: Employee: Person name: String id: int + employeeCount(): int { --------------- return employeecount } + name():String { return name; } - secret():void { ///private method } ...

Scala in java code : $colon

Hi, I read some java source code which including Scala source code. I found Nil.$colon$colon(Object arg) What does keywords $colon mean? And what does this line mean? ...