parentheses

bash functions: enclosing the body in braces vs. parentheses

て烟熏妆下的殇ゞ 提交于 2019-12-02 16:39:18
Usually, bash functions are defined using curly braces to enclose the body: foo() { ... } When working on a shell script today making extensive use of functions, I've run into problems with variables that have the same name in the called as in the calling function, namely that those variables are the same. I've then found out that this can be prevented by defining the local variables inside the function as local: local var=xyz . Then, at some point, I've discovered a thread ( Defining bash function body using parenthesis instead of braces ) in which it is explained that it's just as valid to

Why was the statement (j++); forbidden?

不羁的心 提交于 2019-12-02 14:59:06
The following code is wrong (see it on ideone ): public class Test { public static void Main() { int j = 5; (j++); // if we remove the "(" and ")" then this compiles fine. } } error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement Why does the code compile when we remove the parentheses? Why does it not compile with the parentheses? Why was C# designed that way? Eric Lippert Deep insights appreciated. I shall do my best. As other answers have noted, what's going on here is the compiler is detecting that an expression is being

python assert with and without parenthesis

廉价感情. 提交于 2019-12-02 14:47:29
Here are four simple invocations of assert: >>> assert 1==2 Traceback (most recent call last): File "<stdin>", line 1, in ? AssertionError >>> assert 1==2, "hi" Traceback (most recent call last): File "<stdin>", line 1, in ? AssertionError: hi >>> assert(1==2) Traceback (most recent call last): File "<stdin>", line 1, in ? AssertionError >>> assert(1==2, "hi") Note that the last one does not raise an error. What is the difference between calling assert with or without parenthesis that causes this behavior? My practice is to use parenthesis, but the above suggests that I should not. The last

Ruby Kernel.raise method throws error when enclosing parameters in parenthesis

回眸只為那壹抹淺笑 提交于 2019-12-02 06:44:21
I like method parameters enclosed in parenthesis, this is some Pascal nostalgia. When cleaning up code, if I find a method parameters without it I enclose them immediately. Today it caused my working code throwing errors although my syntax looks okay according to the documentation. Kernel.raise's documentation has this format: (Object) raise(exception[, string [, array]]) These are all working: > raise TypeError TypeError: TypeError > raise (TypeError) TypeError: TypeError > raise "Error message" RuntimeError: Error message > raise ("Error message") RuntimeError: Error message But the enclosed

Missing ) in parenthetical error, but everything seems to be closed off properly

别等时光非礼了梦想. 提交于 2019-12-02 03:49:30
问题 I'm getting the missing ) error from the following code. JS Hint says a ) is expected from the top line, but "if" found instead. denom = (((theZombies[j].y + 15) – theZombies[j].y) * (mouseX – Player1.x) – ((theZombies[j].x + 18) – (theZombies[j].x - 18 )) * (mouseY - Player1.y)); if (denom != 0) {theZombies.splice(j, 1);} But I don't get it -- all the parentheses are closed off properly. I've also looked back in the code and can't find an unclosed one previously. Any ideas what I'm missing?

VB.NET Match string between parentheses (brackets)

試著忘記壹切 提交于 2019-12-02 03:36:55
问题 Looking for a pattern for matching text between brackets. For example: "(this is) a (test)" should output "this is" "test" Using Dim m As Match = Regex.Match(str, pattern, RegexOptions.Multiline) I have searched stackOverflow, Google and tried examples on RegExr and nothing seems to work for me. These work on RegExr but in not VB.NET "\(([^)(]++|(?R))+\)" - error nested quantifier "(?<=\<p\>)(.*?)(?=<\/p\>)" - quantifier following nothing Others will return: "this is) a (test" - matching far

VB.NET Match string between parentheses (brackets)

試著忘記壹切 提交于 2019-12-02 02:03:07
Looking for a pattern for matching text between brackets. For example: "(this is) a (test)" should output "this is" "test" Using Dim m As Match = Regex.Match(str, pattern, RegexOptions.Multiline) I have searched stackOverflow, Google and tried examples on RegExr and nothing seems to work for me. These work on RegExr but in not VB.NET "\(([^)(]++|(?R))+\)" - error nested quantifier "(?<=\<p\>)(.*?)(?=<\/p\>)" - quantifier following nothing Others will return: "this is) a (test" - matching far outer brackets PS I could also do with the same for [],"",{} it would be good to have them all in one

Self executing function passing object after condition

末鹿安然 提交于 2019-12-02 00:42:23
I have come across a self executing function that executes on a condition that the declared containing var exists, and if it doesn't exist it is passed an object. Example: var myFunc = (function(myFunc){}(myFunc || {})); How come there is an "or" condition operator that passes an object ? var myFunc = (function(myFunc){}(myFunc||{})); This doesn't make any sense because the myFunc Argument will always be {} - I'm confused by that. Ill explain one that does First Example var cool = { person: 'john' }; (function( Argument ){ console.log( Argument ); // Result Object {person: "john"} }( cool || {

Missing ) in parenthetical error, but everything seems to be closed off properly

こ雲淡風輕ζ 提交于 2019-12-02 00:11:06
I'm getting the missing ) error from the following code. JS Hint says a ) is expected from the top line, but "if" found instead. denom = (((theZombies[j].y + 15) – theZombies[j].y) * (mouseX – Player1.x) – ((theZombies[j].x + 18) – (theZombies[j].x - 18 )) * (mouseY - Player1.y)); if (denom != 0) {theZombies.splice(j, 1);} But I don't get it -- all the parentheses are closed off properly. I've also looked back in the code and can't find an unclosed one previously. Any ideas what I'm missing? Thanks! Your – characters are atually U+2013 EN DASH es, which are not legal in Javascript. You need to

Single-element parethesized expressions/tuples vs common use of parentheses

喜欢而已 提交于 2019-12-02 00:06:22
Sorry if this is trivial - I am so new to swift, actually I have only looked at the language guide+reference for a few minutes. As far as I understand a parenthesized expression like (2,3) is used to construct a tuple, and (2) is a single-element tuple of type (Int) . But then what happens with common use of parentheses like (2+4) in expression (2+4)*5 ? Is this still a tuple of type (Int) multiplied by an Int ? From Types in the Swift book: If there is only one element inside the parentheses, the type is simply the type of that element. For example, the type of (Int) is Int , not (Int) . So