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
0
votes
2 answers

Pointer to Char Initialization in C

If this code is correct: char v1[ ] = "AB"; char v2[ ] = {"AB"}; char v3[ ] = {'A', 'B'}; char v4[2] = "AB"; char v5[2] = {"AB"}; char v6[2] = {'A', 'B'}; char *str1 = "AB"; char *str2 = {"AB"}; Then why this other one is…
J L
  • 563
  • 3
  • 17
0
votes
2 answers

C++: What does this code do? foo([](){bar();});

I just came across a piece of that I am not able to properly look up on Google. It basically looks like this foo([](){bar();}). Here is what I actually found: ArduinoOTA.onStart([]() { Serial.println("Start"); }); Could someone explain this…
Forivin
  • 14,780
  • 27
  • 106
  • 199
0
votes
1 answer

Ruby: how to generate a json output with braces (brackets, parentheses, curlies) in a new line

for a reference file compare a need the possibility to generate json files, where braces always start in a new line. For Instance, the json hash: my_json = {"Key" => {"Key" => "Value"}} leads after the call of…
0
votes
1 answer

delimitMate not working on vim installed with Pathogen

I'm trying to install delimitMate on vim version 7.3. I am using Pathogen. My other pathogen bundles work, so it is not a problem with my setup. In fact, I've also tried auto-pairs and ClosePairs plugins too, and none of them work. I don't know…
bluejay5
  • 55
  • 1
  • 6
0
votes
1 answer

gcc complaints about braces in initialiser (nested structs)

In chasing down a very opaque bug, I have been trying to compile with no warnings or errors. This part of my code worked fine, but gcc complains about the braces--it says there are braces missing and extra braces. I usually initialise a bit more…
0
votes
3 answers

c++: class constructor instructions inside or outside braces

I am following two different C++ programming courses. One is a mandatory course from my Physics degree, ROOT-oriented, and one is a course from the Informatics degree I chose on my own. The problem is, the examples they give for constructors in…
Jeffrey Lebowski
  • 281
  • 1
  • 2
  • 12
0
votes
1 answer

A regular expression that moves opening { braces to a new line, for C/C++/PHP/etc code

This kind of code structure makes, IMHO, code less readable: int func() { [...] } It's just a matter of taste, but I prefer this one: int func() { [...] } So I've trying to make a regular expression to apply in my text editor in order to make…
Petruza
  • 11,744
  • 25
  • 84
  • 136
0
votes
1 answer

What does [] mean in #{msgs[...]}

I found this in some JSF page. I'm confused and when I googled I didn't really find anything about the syntax with having []…
Hannes
  • 442
  • 1
  • 6
  • 23
0
votes
2 answers

Extract text between braces

I have a string as: MESSAGES { "Instance":[{"InstanceID":"i-098098"}] } ff23710b29c0220849d4d4eded562770 45c391f7-ea54-47ee-9970-34957336e0b8 I need to extract the part { "Instance":[{"InstanceID":"i-098098"}] } i.e from the first occurence of '{'…
0
votes
2 answers

Matching innermost braces with regex or strpos?

I have a sort of mini parsing syntax I made up to help me streamline my view code in cakephp. Basically I have created a table helper which, when given a dataset and (optionally) a set of options for how to format the data will render out a table,…
rich97
  • 2,809
  • 2
  • 28
  • 34
0
votes
4 answers

Checking a String in an array for brace (java)

so i'm currently trying to check whether or not there's a brace in a String in an array, but I can't figure out how its done. public void braceChecker() { String[] code = new String[]{"{} [] () {"}; …
user2789945
  • 527
  • 2
  • 6
  • 23
0
votes
1 answer

What's the difference in instantiating variable with vs. without braces in C++?

#include using namespace std; struct CTest { CTest() { cout << "Constructor called"; } CTest(string s) { cout << "Any constructor with parameters"; } }; int main () { CTest t1; CTest t2{}; } I come from the Java world and…
fytwim
  • 1
  • 2
0
votes
2 answers

css/jquery: on curly braces of variable height

[ This is a follow up from my earlier question Very wide thin curly braces with css or jquery ] Here is a fiddle drawing curly braces: http://jsfiddle.net/q9Bcb/7/ var canvas = document.getElementById('myCanvas'); var context =…
Christian
  • 527
  • 6
  • 19
0
votes
3 answers

PHP: Add optional curly braces to control structures in existing code

I used to omit curly braces in PHP whenever they were not necessary, which - with increasing complexity my programs' control flows - has lead to code that is hard to comprehend and impossible to maintain: if (condition) { while…
0
votes
1 answer

Fixing braces (brace matching) tool

I just finished writing thousands of lines of robotics code that has logic statements upon logic statements upon logic statements just to find out from my compiler that I am missing a brace somewhere. Is there a tool that can automatically search…
mberna
  • 313
  • 5
  • 18