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
20
votes
5 answers

Replacing Text Inside of Curley Braces JavaScript

I am trying to use JavaScript to dynamically replace content inside of curly braces. Here is an example of my code: var myString = "This is {name}'s {adjective} {type} in JavaScript! Yes, a {type}!"; var replaceArray = ['name', 'adjective',…
Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195
19
votes
1 answer

Wrapping multiple statements in braces

Is there a keyboard shortcut in Visual Studio 2010 (I'm using ReSharper 6.1 also) that will allow me to surround a selected block of text with curly braces? I tried "Surround With..." (Ctrl+K, Ctrl+S), but I didn't see an option in the list to…
Matt
  • 2,339
  • 1
  • 21
  • 37
18
votes
4 answers

Escape property reference in Spring property file

I want to escape my Spring propeties file in order to get in my bean property: ${ROOTPATH}/relativePath I have a simple Spring config file that contains:
Stephane
  • 235
  • 4
  • 7
16
votes
1 answer

Meaning of curly braces after the "is" operator

I found in some C# source code the following line: if(!(context.Compilation.GetTypeByMetadataName("Xunit.FactAttribute") is { } factAttribute)) and here is another one: if(!(diagnostic.Location.SourceTree is { } tree)) What is the meaning…
DasOhmoff San
  • 865
  • 6
  • 19
16
votes
3 answers

What do curly braces around a variable in a function parameter mean

I saw this code on a package: const SortableList = SortableContainer(({items}) => { return (
    {items.map((value, index) => )}
Toli
  • 5,547
  • 8
  • 36
  • 56
15
votes
1 answer

Clion Unintialized record type: player

I have started learning C++ a few weeks ago. I am seeing now classes and all the stuff, and I was wondering about object instantiation. In this code: class Player { public: int x, y; int speed; }; int main () { Player player…
vrodriguez
  • 335
  • 3
  • 11
14
votes
2 answers

Are curly braces required in @interface declarations in Objective-c?

The following code compiles: @interface MyClass : ParentClass // missing { // missing } @property (nonatomic, copy) NSString *myString; @end I'm wondering if the curly braces in @interface declarations are actually necessary.
SundayMonday
  • 19,147
  • 29
  • 100
  • 154
14
votes
8 answers

Extra brace brackets in C++ code

Sometimes you run into code that has extra brace brackets, that have nothing to do with scope, only are for readability and avoiding mistakes. For example: GetMutexLock( handle ) ; { // brace brackets "scope" the lock, // must close block /…
bobobobo
  • 64,917
  • 62
  • 258
  • 363
14
votes
1 answer

How do I disable brace completion in Visual Studio 2012?

I have recently upgraded to Visual Studio 2012. Whenever I stand on a curly opening bracket and press tab, it automatically inserts 2 new lines and a closing bracket. {|<- cursor Pressing tab gives me. { | } I wish to disable this behavior.…
Tha Pear
  • 143
  • 1
  • 5
13
votes
6 answers

Curly braces in string {0}

I often see curly braces in a string usually containing a number, such as: string something = "I have {0} cats"; Whilst I can work out what this means, I can say I've never read any documentation relating to its useage. The c# string documentation…
m.edmondson
  • 30,382
  • 27
  • 123
  • 206
13
votes
7 answers

What is the name of this convention for curly braces?

I'm a bit puzzled by the number of developers I see writing methods and classes with curly braces below the class name or the method. What convention are they following? Sun clearly states that the correct declaration would be: // this declaration…
Frankie
  • 24,627
  • 10
  • 79
  • 121
13
votes
4 answers

Add curly braces to ggplot2 and then use ggsave

So this is very relevant to this question and this answer is an excellent solution. The problem is that when I try to export the plot using ggsave the curly braces aren't present. example: library(ggplot2) library(grid) library(pBrackets) x <-…
SamanthaDS
  • 1,123
  • 1
  • 10
  • 18
12
votes
1 answer

std::array initialization

A std::array is essentially a C-style array wrapped in a struct. The initialization of structs requires braces, and the initialization of arrays requires braces as well. So I need two pairs of braces: std::array a = {{1, 2, 3, 4,…
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
12
votes
2 answers

JavaScript Curly braces argument as function parameter

I am not very experienced with javascript and have a question relating to curly braces used around a function parameter, since its not a JSON structure. I am learning nuclear js, and I found some code as example, but I don't understand it well -…
Marcin Kurpiel
  • 175
  • 1
  • 8
12
votes
4 answers

How to use constants with Complex (curly) syntax?

I was surprised to see that the following doesn't work as expected. define('CONST_TEST','Some string'); echo "What is the value of {CONST_TEST} going to be?"; outputs: What is the value of {CONST_TEST} going to be? Is there a way to resolve…
aland
  • 1,824
  • 2
  • 26
  • 43