curly-braces

How to surround code by curly braces in IntelliJ IDEA?

a 夏天 提交于 2019-12-02 23:15:06
How to surround code by curly braces in IntelliJ IDEA? Is there any keyboard-shortcut for such operation? zagyi Yes, try Ctrl + Alt + T (Surround With), then A (Curly Braces). Ajang R Just configure Smart Keys as follow: IDE Settings > Editor > General > Smart Keys > Surround selection on typing quote or brace . From the IntelliJ built-in help: If this check box is selected , the selected text on typing a quote, double-quote or brace, will be surrounded with these characters. If this check box is not selected , then the typed quotes, double-quotes or braces will replace the selection. Just

Can I make Visual Studio place curly braces on the same line as an if statement (in HTML)?

谁说胖子不能爱 提交于 2019-12-02 17:48:57
In Visual Studio while designing MVC views (in .aspx or .ascx files) I often use if statements. When I auto-format (Ctrl-K,D), VS wraps the braces in this really ugly and hard to read way: <% if (Model.UserIsAuthenticated) { %> (some HTML goes here...) <% } %> Is there any way to make Visual Studio auto-format like this instead: <% if (Model.UserIsAuthenticated) { %> (some HTML goes here...) <% } %> Or is there a better way to do this? I don't want to use Razor quite yet, but it looks like it would solve my problem. I'm using VS2010 with Resharper 5, if that helps. felixmm Under Tools →

bash functions: enclosing the body in braces vs. parentheses

て烟熏妆下的殇ゞ 提交于 2019-12-02 16:39:18
Usually, bash functions are defined using curly braces to enclose the body: foo() { ... } When working on a shell script today making extensive use of functions, I've run into problems with variables that have the same name in the called as in the calling function, namely that those variables are the same. I've then found out that this can be prevented by defining the local variables inside the function as local: local var=xyz . Then, at some point, I've discovered a thread ( Defining bash function body using parenthesis instead of braces ) in which it is explained that it's just as valid to

Netbeans PHP - add/remove curly braces plugin/shortcut

佐手、 提交于 2019-12-02 05:48:52
I love short if statements without braces (PHP) like if ($x === $y) echo $z; If I want to add a few lines (maybe just temporary for debugging) I have to manually add the braces. Is there a plugin for netbeans that does that via shortcut, something like "toggle (add/remove) previous statement braces"? The best solution I got for now are two macros Add Curly-Braces: caret-end-line caret-begin-line "{" insert-break Remove Curly-Braces: caret-up caret-end-line remove-word-next selection-match-brace cut-to-clipboard remove-line remove-word-previous insert-break paste-from-clipboard caret-up caret

for loop without braces in java

若如初见. 提交于 2019-12-01 15:29:07
I wonder why this two following codes give different results; for(i = 1, j = 0; i < 10; i++) { j += i; System.out.println(i); } This one gives the numbers between 1 included and 10 excluded. for(i = 1, j = 0; i < 10; i++) j += i; System.out.println(i); However this one gives 10. I could not get the logic of this; for() do_something; do_something_else; That is because the default scope of an iteration in your case is the only line following it, something equivalent to - for(i=1, j=0;i<10;i++) { j += i; } System.out.println(i); Hence the entire loop is iterated and since after that the value of

for loop without braces in java

浪子不回头ぞ 提交于 2019-12-01 13:32:36
问题 I wonder why this two following codes give different results; for(i = 1, j = 0; i < 10; i++) { j += i; System.out.println(i); } This one gives the numbers between 1 included and 10 excluded. for(i = 1, j = 0; i < 10; i++) j += i; System.out.println(i); However this one gives 10. I could not get the logic of this; for() do_something; do_something_else; 回答1: That is because the default scope of an iteration in your case is the only line following it, something equivalent to - for(i=1, j=0;i<10

Practical use of extra braces in C

瘦欲@ 提交于 2019-12-01 11:56:17
I know {} are used to separate entities such as functions, classes and conditional branching, but what other use would they have here? #import <stdio.h> int main(void) { {{{ printf("main\n"); }}} return 0; } EDIT: I found that it may be useful primarily for information hiding, along with nested functions . From the answers below it would seem they can be used as a marker during debugging and be removed in the release, but that this should not be endorsed. Enclosing a code in braces { } creates an Scope . Creating an local scope can have number of reasons like: Allows you to reuse a variable

Parsing URIs that have curly braces, URI::InvalidURIError: bad URI(is not URI?)

假装没事ソ 提交于 2019-12-01 09:30:39
Using ruby 1.9.2-p290. I came across an issue trying to parse a URI like the following: require 'uri' my_uri = "http://www.anyserver.com/getdata?anyparameter={330C-B5A2}" the_uri = URI.parse(my_uri) issuing the following error: URI::InvalidURIError: bad URI(is not URI?) I require a different solution than encoding the curly braces every time like this: new_uri = URI.encode("http://www.anyserver.com/getdata?anyparameter={330C-B5A2}") => "http://www.anyserver.com/getdata?anyparameter=%7B330C-B5A2%7D" Now I can parse the new_uri as usual, but had to do this every time I needed it. What is the

Parsing URIs that have curly braces, URI::InvalidURIError: bad URI(is not URI?)

房东的猫 提交于 2019-12-01 07:56:57
问题 Using ruby 1.9.2-p290. I came across an issue trying to parse a URI like the following: require 'uri' my_uri = "http://www.anyserver.com/getdata?anyparameter={330C-B5A2}" the_uri = URI.parse(my_uri) issuing the following error: URI::InvalidURIError: bad URI(is not URI?) I require a different solution than encoding the curly braces every time like this: new_uri = URI.encode("http://www.anyserver.com/getdata?anyparameter={330C-B5A2}") => "http://www.anyserver.com/getdata?anyparameter=%7B330C

How to access php curly brace object property [duplicate]

亡梦爱人 提交于 2019-12-01 06:00:12
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 ) [3971601] => stdClass Object ( [property1] => 123 [property2] => 356 ) ) How can I using the curly brace syntax with variable to access the sub-object ? I tried: $myObj->'3971601'; // Parse error: syntax error $myObj->{'3971601'}; // Works $id = 3971601; $myObj->{$id}; // Notice: Trying to get property of non-object $id = 3971601; $myObj->{''.$id}; // Notice: Trying to get property of