Questions tagged [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 curly brackets (or braces) "{" and "}" are special cases of brackets, along with parentheses and square brackets ("[" and "]").

Curly brackets have many uses in most programming languages, such as:

  • identify code blocks;
  • create lists and arrays;
  • pass arguments to commands in TeX.
170 questions
4
votes
5 answers

Need to check that braces in given array are balanced or not

Braces in a string are considered to be balanced if they met the following conditions, All braces must be closed. braces come in a pair of the form of (), {}, []. The left brace opens the pair and the right one closes it. In any set of nested…
Bappaditya
  • 8,676
  • 2
  • 15
  • 27
4
votes
1 answer

Eclipse PDT turn off auto insertion of closing bracket in CSS

Eclipse by default will insert closing braces "}" when you type an opening brace "{" for most if not all file formats. This feature can be turned off for most file types in Windows->Preferences but how do you turn it off for CSS files or braces that…
MikeyBunny
  • 557
  • 4
  • 13
4
votes
1 answer

Missing braces for multi-dimensional arrays

When I build my project for an Android shared library in Visual Studio, I got a warning message below. warning : suggest braces around initialization of subobject [-Wmissing-braces] This message is indicating an array initialization statement which…
Jenix
  • 2,731
  • 2
  • 21
  • 50
4
votes
0 answers

R: Add horizontal and vertical braces to boxplot

I'm new here and have very limited skills in R. I'm nearing the completion of my MSc dissertation and need to use R to make some basic graphs, but I'd like to take some to the next level - but I really need some help :(. I can do the basics, but…
4
votes
1 answer

shortcut for creating braces in visual studio

many of time I have a if condition with just one line, like this: if (true) // my single code but sometimes, I want to expend my if condition to 2 or more codes, so I should use braces. if (true) { //do something } I want to know is there…
Elahe
  • 1,350
  • 2
  • 17
  • 33
4
votes
3 answers

Usage of braces without definition of function, struct etc

While analysing of Orchard.cms source code, I've found interesting code, when brackets in C# were used not for definition of any internal object. Seem it was made for some context usage. Can you please clarify what's goal of using brackets like…
Johnny_D
  • 4,384
  • 2
  • 28
  • 63
4
votes
3 answers

Inline braces block within method and loop

It's kind of hard to exactly search for this. I've seen this in a few places and I've even tried it in code to see how it works but just so that I know exactly how they can be used and to make sure I wont be abusing them I thought i'd ask on here. …
Skepi
  • 438
  • 3
  • 12
4
votes
5 answers

Netbeans code format braces in PHP single line statements

Intro Im developing PHP in NetBeans IDE 7.2 (Build 201207171143) and I love the formatting to clean up my code in my custom format. At the moment I work in a group with colleagues. Some of my colleagues are used to write single line statement…
Ron van der Heijden
  • 13,198
  • 7
  • 52
  • 79
3
votes
5 answers

C++ struct array initialization

This is ok: int vec_1[3] = {1,2,3}; so what's wrong with struct arrays{ int x[3]; int y[3]; int z[3]; }; arrays vec_2; vec_2.x = {1,2,3}; that gives: error: cannot convert ‘’ to ‘int’ in assignment I've…
brunetto
  • 173
  • 1
  • 2
  • 7
3
votes
3 answers

Question about why the outer loop does not need braces in this case

For the below code, I do not fully get why braces are not needed for the outer for loop? I know if we had them it would be fine but not fully getting why not having them is fine. You do not need braces if the loop's body is one statement. How is the…
movibayer
  • 31
  • 1
3
votes
2 answers

How to change VS Code settings for Java to put open curly brace on the new line

I have been looking for answer for a long time in google, but unfortunately I haven't found anything. As in topic I am looking for tips to force VS code formatting java files like this: if() { } not this: if(){ }
3
votes
2 answers

Bash: Making cat merge braced files {} in a variable

Problem: cat works reads multiple files within a brace {}; cat {file1,file2}.txt But not when the braced part is specified by a variable. VAR="{file1,file2}" cat $VAR.txt I suspect, as referenced here, this is because quotes are read literally in…
3
votes
0 answers

Resharper Braces auto-format

I have a problem with Resharper and auto formating braces. Since a while Resharper don't add closing braces while I am typing an opening brace. Also when I am typing a closing brace at the last line of a method, the closing brace of the method will…
hwcverwe
  • 4,884
  • 7
  • 31
  • 58
3
votes
4 answers

Regex: Remove a

paragraph that has curly brackets inside

I would like to remove any paragraph for article body that has curly brackets inside. For example, from this piece of content:

While orthotic inserts are able to provide great support and pain relief, they aren’t quite as good as a specialty…

Andrey Kurnikovs
  • 315
  • 1
  • 3
  • 15
3
votes
1 answer

Visual Studio 2015 bracing doesn't work properly

In Visual Studio Ultimate 2013 I could write: public void Foo() And then write left brace + enter and i received: public void Foo() { | <- My cursor's position } But in Visual Studio Community 2015 if I do it too fast i will…
1 2
3
11 12