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...
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?
...
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...
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...
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
...
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 ...
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?
...
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)...
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...
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 ""
...
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?
...
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...
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;
...
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...
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...
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...
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...
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
...
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...
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...