Questions tagged [curly-braces]

The symbols "{" and "}", commonly used in programming languages. Please use this tag only if the specific usage of these symbols is a relevant part of the question.

The symbols "{" and "}", commonly used in programming languages. Please be sure that the specific usage of these symbols is a relevant part of the question.

652 questions
44
votes
5 answers

Why does Golang enforce curly bracket to not be on the next line?

correct: if(true) { } incorrect: if(true) { } Why is this style enforced, does it have something to do with the language spec, or is it just because they prefer one style over another ?
jokoon
  • 6,207
  • 11
  • 48
  • 85
38
votes
4 answers

bash functions: enclosing the body in braces vs. parentheses

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…
flotzilla
  • 1,181
  • 1
  • 13
  • 23
33
votes
6 answers

Java comment at end of brace/block

Is it an accepted practice in the Java programming language to end a brace for a code block with a comment that briefly explains what code block the brace closes off? I personally would think that they are useless comments that clutter the…
ecbrodie
  • 11,246
  • 21
  • 71
  • 120
32
votes
2 answers

C# String.Format with Curly Bracket in string

Possible Duplicate: Escape curly brace '{' in String.Format c# has a String.Format method that allows you to format a string but inserting params with the tokens {0} {1} I am trying to create a simple json string which requires curly brackets to…
MattoTodd
  • 14,467
  • 16
  • 59
  • 76
32
votes
4 answers

What Is a Curly-Brace Enclosed List If Not an intializer_list?

I asked a question here: Lifetime Extension of a initializer_list return involving the non-functional code: const auto foo = [](const auto& a, const auto& b, const auto& c) { return {a, b, c}; }; I believed the lambda was trying to return an…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
32
votes
3 answers

Curly Brackets in Arrow Functions

can someone, please explain the following: I'm following Dan Abramov's lectures & doing the exercises. The code works fine, however, the tests fail when the following particular function is written with curly brackets **{ }**. case 'toggleTodo'…
Kayote
  • 14,579
  • 25
  • 85
  • 144
32
votes
2 answers

Do curly braces inside json string objects need to be escaped?

This string is part a JSON object/file: "Mask" : "{0}(CASE WHEN {1} = {2} THEN {3} ELSE 0 END) {4}" Will JSON recognize that as part of standard JSON notation or do I need to escape those curly braces s somehow? If so, how does one escape curly…
A.G.
  • 2,089
  • 3
  • 30
  • 52
27
votes
1 answer

Why can in-class initializers only use = or {}?

In-class initializers (C++11 feature) must be enclosed in curly braces or follow a = sign. They may not be specified inside parenthesis. What is the reason for this?
7cows
  • 4,974
  • 6
  • 25
  • 30
26
votes
4 answers

Use curly brackets to structure code in PHP

Is it possible to enclose code fragments in PHP within brackets (without using the fragment as a function)? Would the following code behave the same way as it would without the curly brackets? Or might there be any problems depending on what kind of…
Albin
  • 1,000
  • 1
  • 11
  • 33
25
votes
5 answers

curly braces when define array

Regards to the following code: int[] to = new int[] { text }; I understand it tries to define an array of integer, but What does the curly braces do in array definition?
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
25
votes
3 answers

CURL to pass SSL certifcate and password

I need to specify a certificate with CURL i tried with --cert option it is not working. Could you please let me know to specify the keystore and passpharse while invoking with curl?
Adam
  • 727
  • 4
  • 11
  • 21
24
votes
1 answer

Three curly brackets together in php source code

I just downloaded complete source code of PHP from php.net (PHP 5.4.0 [tar.bz2]). They are often using three curly brackets together as given below (The following code snippet extracted form ext/ctype/ctype.c.) /* {{{ proto bool ctype_digit(mixed…
Mohammed H
  • 6,880
  • 16
  • 81
  • 127
23
votes
1 answer

How do {{}} double curly brackets work in dplyr?

I saw Hadley's talk at RConf and he mentioned using double brackets for calling variables in tidy evals. I searched Google but I couldn't find anything talking about when to use them. What's the use case for double brackets in dplyr?
Cauder
  • 2,157
  • 4
  • 30
  • 69
23
votes
2 answers

How to fix ReSharper indentation on object & other initializers

I have found other duplicates of this question, but they are very old and the solutions are not applicable to R#8, because the settings have changed. When I do anonymous type or object initialization (any kind of curly brace indentation with…
danludwig
  • 46,965
  • 25
  • 159
  • 237
21
votes
3 answers

Curly Braces Notation in PHP

I was reading source of OpenCart and I ran into such expression below. Could someone explain it to me: $quote = $this->{'model_shipping_' . $result['code']}->getQuote($shipping_address); In the statement, there is a weird code part that…
Tarik
  • 79,711
  • 83
  • 236
  • 349
1 2
3
43 44