Questions tagged [curly-brackets]

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.
85 questions
77
votes
7 answers

List of all unicode's open/close brackets?

What is a list of every unicode bracket-like characters (including, for example: {}[]()<>)? What is a good way to search for unicode characters?
MaiaVictor
  • 45,122
  • 42
  • 127
  • 254
21
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
  • 597
  • 5
  • 23
18
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,188
  • 1
  • 20
  • 34
13
votes
4 answers

How to navigate to a closing bracket with ReSharper?

Say you have a large amount of C# code in an if statement. If you place your carat next to the opening bracket, is there a hotkey or something in ReSharper that will automatically take you to the closing bracket?
Dan Appleyard
  • 7,195
  • 13
  • 47
  • 79
13
votes
4 answers

Is there an auto-close curly brackets plugin for the Geany IDE?

Geany is the closest thing I can find to the perfect web development IDE. However, I can't find a way to automatically close curly brackets ({). For example, typing: function test() { ..and pressing RETURN should cause this to happen: function…
xLite
  • 1,331
  • 1
  • 14
  • 27
12
votes
1 answer

How can I print a string using .format(), and print literal curly brackets around my replaced string

Possible Duplicate: How can I print a literal “{}” characters in python string and also use .format on it? Basically, I want to use .format(), like this: my_string = '{{0}:{1}}'.format('hello', 'bonjour') And have it match: my_string =…
12
votes
2 answers

rules (?) of parens/brackets usage in perl

Did some search but couldn't find anything useful. I was wondering if there is a summary table of sort for beginners to learn about the "rules" of using parens/brackets, specifically, the differences among (), [], {}. Unfortunately, in my…
B Chen
  • 883
  • 2
  • 12
  • 20
12
votes
2 answers

Is it true that I should use K&R styling when writing javascript?

I didn't realise it until recently, but I use the Allman style when writing javascript code. According to http://encosia.com/in-javascript-curly-brace-placement-matters-an-example/ I should be using K&R style. This is because in some situations…
TryHarder
  • 2,433
  • 8
  • 44
  • 60
8
votes
5 answers

1TBS for long conditional expressions

Important note: this question is not about the superiority of a bracing style above another. I am currently switching styles in order to evaluate for myself which one I think works best in my situation, and I like Allman as much as 1TBS. Users of…
Gauthier
  • 34,041
  • 11
  • 53
  • 87
6
votes
2 answers

consecutive operators and brackets

I'm just trying to learn a bit of Perl and have come across this: foreach $element (@{$records}) { do something; } To my newbie eyes, this reads: "for each element in an array named @{$records}, do something" but, since that seems an…
Robert
  • 5,191
  • 43
  • 59
  • 113
5
votes
3 answers

Why am I getting ugly curly brackets around my text in the label widget? - Tkinter

I'm getting curly brackets around the text in my label widget. The output is {Total tries: 0} instead of Total tries: 0. Here is a short version of my code: class Cell: def check(self): mem.tries += 1 mem.update_tries() class…
Amazon
  • 105
  • 3
  • 9
5
votes
1 answer

How to access php curly brace object property

Possible Duplicate: How to access object properties with names like integers? print_r($myObj) gives the following result: stdClass Object ( [4021450] => stdClass Object ( [property1] => ooo [property2] => xxx ) …
Bossliaw
  • 690
  • 1
  • 9
  • 23
5
votes
2 answers

Java - Switch statement and curly braces

I have a question associated with curly braces in switch-case block switch( conditon ) { case val1: { // something } break; case val2: { // something } break; default: break; } or something like this: …
Michał Ziobro
  • 7,390
  • 6
  • 50
  • 99
5
votes
5 answers

Is the curly brackets object notation valid in any expression?

I'm currently analyzing the Javascript language a bit. It looks like you could group at lot of the concepts into a base type called expression. Even function arguments and definitions fit into that group, as well as strings, numbers and mathematical…
schwer
  • 249
  • 1
  • 2
  • 9
4
votes
4 answers

When are curley braces required around single statements?

In my answer here: C# Lock syntax - 2 questions, LukeH pointed out that try...catch...(finally) statements require curly braces. I found the answers as to why, found here ( Why do try..catch blocks require braces? ) very interesting. I'd like to…
George Duckett
  • 29,922
  • 7
  • 92
  • 154
1
2 3 4 5 6