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.
82 questions
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
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,405
  • 14
  • 49
  • 80
13
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 =…
Simon Lundberg
  • 1,413
  • 2
  • 11
  • 23
13
votes
5 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,441
  • 3
  • 15
  • 28
13
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,704
  • 8
  • 47
  • 65
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
  • 923
  • 2
  • 12
  • 21
8
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
  • 10,759
  • 11
  • 88
  • 143
8
votes
2 answers

Use of curly braces with object construction

Studying Xamarin I've come across this kind of use of curly braces: Label header = new Label { Text = "Label", Font = Font.BoldSystemFontOfSize(50), HorizontalOptions = LayoutOptions.Center }; And I'm wondering how it can be correct…
nix86
  • 2,837
  • 11
  • 36
  • 69
7
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
  • 40,309
  • 11
  • 63
  • 97
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,278
  • 43
  • 65
  • 115
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
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
  • 279
  • 1
  • 2
  • 10
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
  • 31,770
  • 9
  • 95
  • 162
4
votes
1 answer

Do both parentheses and braces around expressions basically do the same thing?

Simply put, are these two for cycles functioning the same way: for (int i = 0; i < (p_size < size ? p_size : size); i++); for (int i = 0; i < {p_size < size ? p_size : size}; i++); ? The loop is inside a method (member function), p_size is its…
Stefan Stanković
  • 628
  • 2
  • 6
  • 17
3
votes
4 answers

Is this html code using php inside it without the signs?

{$smarty.section.page.index} {/if} {/section} {if $pagesArray.is_next_page eq 'Y'}
Simon Suh
  • 10,599
  • 25
  • 86
  • 110
1
2 3 4 5 6