Menu
  • HOME
  • TAGS

Swift Types inside Parentheses

types,swift,parentheses

Partly it's that parentheses are meaningful. let g = (5) ...means that g is to be a tuple consisting of one Int, symbolized (Int). It's a one-element version of (5,6), symbolized (Int,Int). In general you need to be quite careful about parentheses in Swift; they can't just be used any...

warning: suggest parentheses around assignment used as truth value in for loop

for-loop,warnings,parentheses

The compiler is simply calling your attention to the assignment in the for loop. It is probably doing so because the "for" statement has 3 semicolon-delimited expressions which is rather dense and prone to human error. By changing for (int i = N-1; i = 0; i--) to for (int...

Regexp replace everything between parenthes

ruby,regex,replace,parentheses

You can match balanced parentheses in Ruby with conditionals: \bgrouping(\((?>[^()]|(\g<1>))*+\)) See demo Here is how you can do it in Ruby: rx = /\bgrouping(\((?>[^()]|(\g<1>))*+\))/ txt = "grouping(elllo)\n\ngrouping(function() {\n console.log(\"hello\")\n})" puts txt.gsub(rx) { |m| m.gsub($~[1], '(NEWTEXT)') } See IDEONE demo...

Check if an operator is nested inside parenthesis

java,expression,parentheses

The condition as it is expressed now can never return true: int i = exp.lastIndexOf('(', lastMD); if (i != -1 && i < lastMD && i > i) { ... i > i will always evaluate to false. As a side note, as already pointed out in the comments, you...

Oracle sql - ORA-00907 and my incorrect syntax

oracle,parentheses,ora-00907

You have a semi-colon at the last but 1 line. GROUP BY application_number; ) Remove it and you should be fine. Semi-colon acts as the query terminator in Oracle, as you had placed it before the ) Oracle could not find it. ...

Disable parenthesis matching in emacs

emacs,parentheses

Emacs doesn't do that by default, that sounds like ParEdit. You might be able to derive from the installation description how to get rid of it.

Give example of actual Parenthesis Hell program

haskell,lisp,parentheses

I don't think it expects code in its arguments. It looks to me like it looks for filenames (and a command line option named -v). It also seems like it only accepts one parenthesized expression per program. So something like () (()) would be invalid but (() (())) would be...

How to set parenthesis in column name in create table Sql query

sql-server,parentheses,columnname

Just put it inside [] create table temp_sp ( logtime datetime, vcs_api varchar, [L3(S1)Status] varchar, [L3(S2)Status] varchar, beam_current real, beam_energy real, st1_vs1_bag1_rb real, ring_avg_pressure real ) EDIT: As the comment below stated: You should not leave variable length fields with an unspecified length. VARCHAR and NVARCHAR has two defaults, 1...

bash functions: enclosing the body in braces vs. parentheses

bash,function,parentheses,curly-braces

Why are braces used by default to enclose the function body instead of parentheses? The body of a function can be any compound command. This is typically { list; }, but three other forms of compound commands are technically allowed: (list), ((expression)), and [[ expression ]]. C and languages...

C++ code mandatory parenthesis [closed]

c++,algorithm,object,compiler-construction,parentheses

First of all, what you are talking about is not parenthesis, its curly braces. for (kf=0; kf<nf; kf++) if (EPS_MOCK[kf] == 1) for (i=0; i<nptsx; i++) for (j=0; j<nptsz; j++) Compiler will definitely support this type of syntax, but it will be confusing, to make your code more readable, follow...

Ruby: doesn't allow to put whitespace after 'yield'

ruby,yield,parentheses

The yield keyword is behaving no differently from the method invocation syntax. If you have a space between a method name and the parentheses containing the method's arguments, the interpreter parses the parentheses as passing a single argument that is the result of the expression inside of the parentheses. Take...

Unclosed Group Error with Parentheses when Replacing an Expression

java,regex,replace,parentheses

replaceAll(String regex, String replacement) - so argument "3(4" is treated as regular expression. To use it as it is you need to quote it: Pattern.quote(numbers[i]).

When do extra parentheses have an effect, other than on operator precedence?

c++,c++11,language-lawyer,parentheses,c++-faq

TL;DR Extra parentheses change the meaning of a C++ program in the following contexts: preventing argument-dependent name lookup enabling the comma operator in list contexts ambiguity resolution of vexing parses deducing referenceness in decltype expressions preventing preprocessor macro errors Preventing argument-dependent name lookup As is detailed in Annex A of...

Using paranthesis for calculation in Java [duplicate]

java,parentheses

The problem is that integer division doesn't take into account fractional numbers. So 20 / 100 == 0. In your specific example, since * and / have same precedence and are left-associative then income * 20 / 100 is evaluated as (income * 20) / 100 That's why the result...

clojure terminating paranthesis syntax

clojure,compiler-construction,parentheses

Yes, you could do this, even without reader macros (in fact, you can change Clojures syntax with a bit of hacking). But, the question is, what would it gain you? Would it always expand to top-level? But then cutting and pasting code would fail, if you moved it to or...

how to change the value of sp-navigate-reindent-after-up in smartparens

emacs,lisp,elisp,parentheses

I am not a smartparens user but I found the answer from its wiki: You can bind ) to sp-up-sexp command: (define-key smartparens-mode-map ")" #'sp-up-sexp) ...

Conditional statement in daa.R of the R “matchingMarkets” library

r,conditional-statements,parentheses

When you ask R if 0 %in% x where x is a logical vector, R will first convert x to a numeric vector where FALSE becomes 0 and TRUE becomes 1. So essentially, asking if 0 %in% x is like asking if x contains any FALSE. This is arguably pretty...

Defining variable with multiple values in parentheses uses 2nd value [duplicate]

javascript,variables,parentheses

Because that's how the comma operator works: It evalutes both its operands, and the result of the expression is the value of the second one. Note that this is very different from what you'd have if you didn't have the parentheses there: // Differs *significantly* from your example: var x...

Indices of matching parentheses in Python

python,parentheses

You mean an automated way? I don't think so. You need to create a program using stack, in which you push the index when you find an open parenthesis, and pop it when you find a closing parenthesis. In Python, you can easily use a list as a stack, since...

How to find all possible regex matches in python?

python,regex,parentheses

it's actually not possible to do this by using regular expressions, because regular expressions express a language defined by a regular grammar that can be solved by a non finite deterministic automaton, where matching is represented by states ; then to match nested parenthesis, you'd need to be able to...

Literal parenthesis with python regex

python,regex,parentheses

You can use re.escape to handle this: regexString = '(?<= = ")' + re.escape(original) + '(?=")' ...

Parentheses in string of javascript function call

javascript,jquery,syntax-error,parentheses

The parenthesis aren't the problem, it's the lack of quotes inside the function. formResults += "<a onclick='openForm(\'" + this.displayText + "," + this.ID + "\');'>" + this.displayText + "</a>"; This below snippet (from yours) `openForm(Example Form...`) Will throw an error because it's looking for variables Example and so on, quote...

Is the Parenthesis -> Bracket optimization for R code still relevant?

r,optimization,parentheses,brackets

Seems to still be relevant for me. That doesn't mean I'm losing any sleep over it. version # platform x86_64-w64-mingw32 # arch x86_64 # os mingw32 # system x86_64, mingw32 # status # major 3 # minor 2.1 # year 2015 # month 06 # day 18 # svn rev...

VBA What's the underlying difference between call Sub or Function with or without parentheses

arrays,vba,call,parentheses,byref

Great question! I believe the parentheses are causing an evaluation, so even though the function is taking the argument ByRef, you're not actually passing it the array local to the calling procedure, you're passing essentially a copy of it. To avoid ambiguity, I tend to make Sub all procedures that...

Can we remove parentheses around arguments in C macros definitions?

c,macros,c-preprocessor,parentheses

Here's a relatively dumb example, but it does have a different result: #define Streq(s1, s2) (strcmp((s1), (s2)) == 0) #define MyStreq(s1, s2) (strcmp(s1, s2) == 0) #define s1 "foo", "blah" int main() { Streq(s1, "blah"); // Compiles and compares equal. MyStreq(s1, "blah"); // Compiler error. Too many parameters. } ...

AS3 switch/case difference with or without parenthesis

actionscript-3,switch-statement,case,parentheses

There is no difference. This would also be valid: switch { case "A": { { // some code break; } } } You can add a { } block wherever you like....

Is it mandatory to enclose an entire ternary operator statement in parenthesis in this statement?

php,ternary-operator,parentheses,readability,code-readability

The original intent was readability I guess or maybe the developer was just following a Coding Standard. Though wrapping and indenting would help on readability way more than adding unnecessary parenthesis. Like this for exmaple: $class = is_array($tagClasses) ? 'class="' . implode(" ", $tagClasses) . '"' : ''; When you...

Do parentheses make a difference when determining the size of an array?

c,arrays,language-lawyer,sizeof,parentheses

Whether seemingly redundant parentheses affect the semantics of a program is a long-standing issue in the C standard that still hasn't been adequately resolved. It is commonly claimed that ((void*)0) is technically not a null pointer constant, because there is no rule that says a parenthesised null pointer constant is...

Find String Inside Outermost Parenthesis

c++,string,nesting,parentheses,repetition

Lest pseudo code be the only answer I've taken it upon myself to answer this using standard algorithms: string foo{ "this (is(maybe)) a test (and maybe not)" }; auto start = find(foo.begin(), foo.end(), '('); auto count = 0; auto finish = find_if(start, foo.end(), [&count](char i){ if (i == '('){ count++;...

coffeescript chaining with no parameters?

methods,coffeescript,chaining,parentheses

Short answer: no, you can't. That exact syntax will not work in CoffeeScript. You can only chain methods that have at least one argument, so something like this could work: myFunction arg1 .chain1 arg2 .chain2 arg3 For jQuery, for example, you can do stuff like: $ -> $ '#foo' .and...

How to disable Emacs highlighting whitespace in parenthesis?

emacs,whitespace,parentheses

Unfortunately the solution given by Ignacy Moryc, didn't help me, but this one helped: (setq sp-highlight-pair-overlay nil) ...

Extract data from within parenthesis in python

python,dictionary,parentheses

Now that was interesting. You really nerd-sniped me on this one... def parse(tokens): """ take iterator of tokens, parse to dictionary or atom """ dictionary = {} # iterate tokens... for token in tokens: if token == ")" or next(tokens) == ")": # token is ')' -> end of dict;...