syntax

How to refer to a static constant member variable in PHP

I have a class with member variables. What is the syntax in PHP to access the member variables from within the class when the class is being called from a static context? Basically I want to call a class method (but not create a new object), but when the class method is called, I want a handful of static constant variables to be initia...

Ruby methods equivalent of "if a in list" in python?

In python I can use this to check if the element in list a: >>> a = range(10) >>> 5 in a True >>> 16 in a False How this can be done in Ruby? ...

Possible syntax for multi-type catch blocks in C#?

Here are two previous questions regarding this topic: Catch multiple Exceptions at once? More Elegant Exception Handling Than Multiple Catch Blocks? I was working today and thought this might be an appropriate syntax should this feature ever be added to the C# language. Anyone have any opinions about it? The type of e must be a base...

php best practices enforcement

I try to ensure that the code I write is of the best quality possible, so I strive to follow accepted sets of best practices. In perl, I try to follow the guidelines in the popular book "Perl Best Practices" and I use the perlcritic module to enforce the policies recommended in that book. Perlcritic checks my code to ensure that each re...

How do I search set of keywords from keywords field in Solr?

So I have a keyword field with this schema Indexed, Tokenized, Multivalued, TermVector Stored, Omit Norms then I wanna search set of keywords against it like q=keyword:keyword1, keyword2, keyword3, etc, etc and want to return most matching keywords, even 1 match keyword is fine, but ordered by most match. thank you ...

How to enclose values in SQL commands?

An error-free column name syntax is [My Column] instead of My Column which causes an error. An error-free string value syntax is '25,00' instead of 25,00 which causes an error. I'm getting an error using single quotes to enclose values, if the column data type is numeric. Are there any other ways to enclose values safely for string or ...

JavaScript Whitespace Syntax Error

Why does this cause a syntax error for the return statement: var FOO = (function($) { return { init: function() { } } })(jQuery); Whereas this doesn't: var FOO = (function($) { return { init: function() { } } })(jQuery); Why is there a difference? ...

scala anonymous function syntax

I'm learning more about Scala and I'm having a little trouble understanding the example of anonymous functions here http://www.scala-lang.org/node/135. I've copied the entire code block below: object CurryTest extends Application { def filter(xs: List[Int], p: Int => Boolean): List[Int] = if (xs.isEmpty) xs else if (p(xs.head)...

C++ const keyword - use liberally?

In the following C++ functions: void MyFunction(int age, House &purchased_house) { ... } void MyFunction(const int age, House &purchased_house) { ... } Which is better? In both, 'age' is passed by value. I am wondering if the 'const' keyword is necessary: It seems redundant to me, but also helpful (as an extra indication th...

Tool to help write Excel formulas and IF statements?

This is an Excel formula with nested IF statements: =IF((B2="East"),4,IF((B2="West"),3,IF((B2="North"),2,IF((B2="South"),1,"")))) To essentially accomplish this: If cell B2 = "East" return "4" ElseIf cell B2 = "West" return "3" ElseIf cell B2 = "North" return "2" ElseIf cell B2 = "South" return "1" Else return "" ...

PHP $_ENV where are they stored

Hi I've compiled my own PHP / apache setup on our dev box at work. However the $_ENV['SERVER_Name']; isn't showing anything. Why is this? ...

How does ScalaTest syntax work?

I've done some programming in Scala, and I know that, e.g., xs map f is the same thing as xs.map(f) but I have no idea how to generalize this syntax to something like ScalaTest's syntax, e.g., it should "throw NoSuchElementException if an empty stack is popped" in { val emptyStack = new Stack[String] evaluating { emptyStack.po...

C++ operator overloading, understanding the Google style guide

I am following a book to learn C++ (come from a python background). I've written this, which works: class CatalogueItem { public: CatalogueItem(); CatalogueItem(int item_code, const string &name, const string &description); ~CatalogueItem() {}; bool operator< (const CatalogueItem &other) const; ...

How to find an ArrayCollection item with a specific property value?

I have some XML structures like this: var struct:XML = <mh> <mi id="1" stuff="whatever"/> <mi id="2" stuff="whatever"/> <mi id="3" stuff="whatever"/> </mh>; I know I can access a subnode by "id", in this way: var stuff:Object = struct.(hasOwnProperty('@id') && @id == '2').@stuff; Now I have some similar ArrayCollection struct...

Syntax (probably BNF) spec of VBA ?

Hi, I have to maintain a portion of Access 2003 VBA code, which is not my primary programming language, and while I'm pretty solid on doing regular stuff, I would still like to have a pure spec of the language syntax.. It just saves a lot of time compared to reading tons of stupid tutorials that tell me what a for loop is. Is there any...

Visual C++ compiling error

When compiling these two files I am getting numerous errors. Please help me out. stchart.cpp # include "peg.hpp" # include "stchart.hpp" # include "stchart_res.hpp" external PegResourceTable stchart_ResourceTable; PEGINT gChartData [] = (100, 100, 100, 100, 100, 100, 125, 150, 175, 200, 150, 100, 50, 100...

Quick PHP question

Hello, I have the following excerpt: if (empty($last_db_error)) { echo "OK"; } else { echo "Error activating subscription."; echo "{$last_db_error}"; } The problem is that "{$last_db_error}" is not shown, unless I use just $last_db_error, without the quotes and brackets. Am I missing something here? Isn't the above syntax...

Does === exist in jquery

I'm aware of the === operator in PHP which connotes not only value equality, but type matching also i.e. if (20 === "20") //false Is there something similar in javascript if I'm using jquery? Examples code could help too. Thanks ...

Python def function: How do you specify the end of the function?

I'm just learning python and confused when a "def" of a function ends? I see code samples like: def myfunc(a=4,b=6): sum = a + b return sum myfunc() I know it doesn't end because of the return (because I've seen if statements... if FOO than return BAR, else return FOOBAR). How does Python know this isn't a recursive functio...

Python noob question: simple syntax error

I'm not sure if this site is for dumb troubleshooting questions, but I figure this will take someone 2 seconds. My Code: #!/usr/bin/env python def Runaaall(aaa): Objects9(1.0, 2.0) def Objects9(aaa1, aaa2): If aaa2 != 0: print aaa1 / aaa2 The error I receive: $ python test2.py File "test2.py", line 7 If aaa2 != 0: print...