5
голосов
2ответов
1748 просмотров

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 ...

0
голосов
4ответов
1705 просмотров

PHP $_ENV where are they stored

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?

2
голосов
4ответов
20245 просмотров

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 = ...

25
голосов
12ответов
12165 просмотров

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 ...

15
голосов
3ответов
9042 просмотров

Anonymous Scala function syntax

I'm learning more about Scala, and I'm having a little trouble understanding the example of anonymous functions in 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] = ...

8
голосов
1ответов
1324 просмотров

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() { } } })...

0
голосов
4ответов
1296 просмотров

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 wa...

4
голосов
1ответов
4919 просмотров

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...

1
голосов
6ответов
1081 просмотров

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 opinio...

18
голосов
2ответов
10280 просмотров

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?

11
голосов
2ответов
10540 просмотров

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...

39
голосов
2ответов
25027 просмотров

How to write an empty indentation block in Python?

The runtime keeps telling me: expected an indented block But I don't want write nothing inside my except block, I just want it to catch and swallow the exception.

0
голосов
1ответов
55 просмотров

Can I avoid rewriting a table expression in an update?

Suppose you're updating a table that is the result of an expression, like so UPDATE OPENQUERY( server, 'SELECT a from b' ) SET rem.a = loc.a FROM OPENQUERY( server, 'SELECT a from b' ) rem ,local_table loc WHERE rem.id = loc.id Will that OPENQUERY be executed once, or twice? I bel...

266
голосов
7ответов
218640 просмотров

Ruby - test for array

What is the right way to: is_array("something") # => false (or 1) is_array(["something", "else"]) # => true (or > 1) or to get the count of items in it?

1
голосов
9ответов
976 просмотров

PHP echo question?

Do I really need this many echo's or can I make it shorter? <?php if (!empty($url)) { echo '<p>Job: <span>' . $job .'</span></p>'; echo '<p>Skills: <span class="caps">' . $skills . '</span></p>'; echo '<p>Website: <a href="h...

0
голосов
3ответов
782 просмотров

Jquery GET - sending & recieving long, complex content, how to?

I have a review PAGE with a TEXTFIELD. User need to be able to write LONG STORY (1000 words+) may contain chars like ()*&^%$#@\/<> Once "save" is pressed I want to use Jquery GET -> to process content with PHP file. (save in mysql database) and return result. let's say I want to ...

16
голосов
9ответов
6094 просмотров

How to indicate when purposely ignoring a return value

In some situations using C/C++, I can syntactically indicate to the compiler that a return value is purposely ignored: int SomeOperation() { // Do the operation return report_id; } int main() { // We execute the operation, but in this particular context we // have no use of the...

0
голосов
3ответов
1513 просмотров

Correct PHP Session and variable syntax

The following syntax is incorrect: $_session['page'$numberpages]=$CurrentPage; What is the correct syntax?

27
голосов
8ответов
26620 просмотров

What does ‘::’ (double colon) do in JavaScript?

The documentation of some JavaScript APIs shows the following snippets as an example of how to invoke some function: <button type="button" onClick="foo.DoIt(72930)">Click</button> <button type="button" onClick="foo.DoIt(42342::37438)">Click</button> :: is obviously use...

4
голосов
2ответов
238 просмотров

what is the difference between a syntax and s-expressions

what is the main differences between syntax language and s-expressions language ? does using s-expressions affects compiling time (in the parsing process) or does it bring any advantage to the language ?

8
голосов
1ответов
1365 просмотров

How do you escape a reserved word in Delphi?

I need to Escape a reserved word to use it as an identifier in Delphi. I thought that was accomplished by using the ampersand "&", but that doesn't seem to be working right. Any other suggestions?

37
голосов
1ответов
21464 просмотров

LINQ: dot notation equivalent for JOIN

Consider this LINQ expression written using query notation: List<Person> pr = (from p in db.Persons join e in db.PersonExceptions on p.ID equals e.PersonID where e.CreatedOn >= fromDate orderby e.Create...

0
голосов
4ответов
901 просмотров

Java Syntax: Shortcuts in Method Declarations?

Quickie pseudo-aesthetics question: For field declarations, the following is allowed: int i, j, k; providing three variables for integers. Does anything similar exist for method declarations, ala: public int getI() {/* ... */}, getJ() {/* ... */}, getK() {/* ... */}; so that the method ac...

147
голосов
10ответов
155860 просмотров

Best way to split string into lines

How do you split multi-line string into lines? I know this way var result = input.Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); looks a bit ugly and loses empty lines. Is there a better solution?

7
голосов
8ответов
9203 просмотров

Best syntax to create multi-line string

What's the best way to create multi-line string in C#? I know the following methods: Using StringBuilder var result = new StringBuilder().AppendLine("one").AppenLine("two").ToString() looks too verbose. Using @ var result = @"one two" looks ugly and badly formatted. Do you know be...

43
голосов
13ответов
52802 просмотров

What's the difference between "LIKE" and "=" in SQL?

Is there any difference between: SELECT * FROM users WHERE username="davyjones" and SELECT * FROM users WHERE username LIKE "davyjones" (I think I've bungled up the syntax... pardon me for that, I'm mostly a desktop app development guy)

28
голосов
8ответов
46195 просмотров

php : echo"", print(), printf()

Is there a better way to output data to html page with PHP? If I like to make a div with some var in php, I will write something like that print ('<div>'.$var.'</div>'); or echo "'<div>'.$var.'</div>'"; What is the proper way to do that? Or a better way, fill a $te...

2
голосов
3ответов
1606 просмотров

Abbreviation for PHP's array()

I don't know how about you, but I'm not very fond of the way arrays are constructed in PHP. I have this feeling that I use array keyword way too often and that array($k => $v) or e.g. array($k1=>array($k2=>$v)) are way too long given usefulness of maps. (Moreover, recently I've learned J...

33
голосов
8ответов
19942 просмотров

WITH statement in Java

In VB.NET there is the WITH command that lets you omit an object name and only access the methods and properties needed. For example: With foo .bar() .reset(true) myVar = .getName() End With Is there any such syntax within Java? Thanks!

0
голосов
11ответов
482 просмотров

Compiler Design

Is newline and whitespaces the same in compiler design? what if you write a macro to replace newlines by whitespaces, is this correct or would it cause some form of problems?