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.
195 questions
4
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
  • 183
  • 1
  • 2
  • 7
4
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(){ }
ClearAngel
  • 41
  • 1
  • 2
4
votes
1 answer

Why this compound statement as a sequence of statements enclosed by braces and inside parentheses does not appear to be a valid statement expression

Why this compound statement as a sequence of statements enclosed by braces (in GNU C++) and inside parentheses does not appear to be a valid Statement expression. // my second program in C++ #include using namespace std; int main () { …
K.Karamazen
  • 176
  • 1
  • 8
4
votes
3 answers

Brackets in ES6 JavaScript

I'm desperate for someone to give me just some concise information about when I should use which brackets where and why in JS ES6. I know the basics but when we start talking about arrow syntax I just lose it and then can't see why we're wrapping…
Maximilian
  • 537
  • 7
  • 18
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
  • 647
  • 6
  • 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,996
  • 2
  • 29
  • 58
4
votes
2 answers

Powershell: Does calling .NET a function always require parenthesis?

I know that PowerShell function calls don't need specific parentheses like C#, but when I try to call .NET class functions, it seems parentheses are always needed, like: [Int32]::Parse("12") So is this a syntax rule?
vik santata
  • 2,989
  • 8
  • 30
  • 52
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
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,592
  • 3
  • 33
  • 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
  • 478
  • 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
  • 14,803
  • 7
  • 58
  • 82
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

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
  • 5,287
  • 7
  • 35
  • 63
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
  • 407
  • 1
  • 5
  • 21
1 2
3
12 13