problem about braces-Collection of common programming errors


  • DigitalTrauma
    bash grouping parentheses semicolon braces
    I know the difference in purpose between parentheses () and curly braces {} when grouping commands in bash.But why does the curly brace construct require a semicolon after the last command, whereas for the parentheses construct, the semicolon is optional?$ while false; do ( echo “Hello”; echo “Goodbye”; ); done $ while false; do ( echo “Hello”; echo “Goodbye” ); done $ while false; do { echo “Hello”; echo “Goodbye”; }; done $ while false; do { echo “Hello”; echo “Goodbye” }; done bash: syntax er

  • Matt B
    objective-c square braces
    This question already has an answer here:Performance difference between dot notation versus method call in Objective-C5 answersI’m currently learning objective-c. What exactly do the square braces around things signify and is there any difference between using that and using a period (I’m from a .NET world so this would be simpler for me).Thanks.

  • Chad
    php mysql braces
    I know this topic has been beaten into the ground, but I’m really stumped. I can’t figure out why I’m getting an unexpected } error. My problem is with a code snippet I’ve added to a Paypal credit card terminal script. It captures the form data into a MySql database so we can keep track of billing address information, etc. It works until I add an IF statement that is supposed to only send the data to MySQL if Paypal successfully successfully captures the card info. I want to do it this way becau

  • B3ret
    braces xkeyval
    I have defined my own figure command using xkeyval and I want to pass arguments for the nested \includegraphics as one of its keyvalues (maybe I stripped too much code, but I hope you get the idea):\makeatletter\define@key[foo]{bar}{options}{\def\FooBarOptions{#1}}\define@key[foo]{bar}{label}{\def\FooBarLabel{#1}}\define@key[foo]{bar}{caption}{\def\FooBarCaption{#1}} \makeatother%\MySpecialFigure[keyvals]{filename} \newcommand{\MySpecialFigure}[2][]{%\begingroup\setkeys[foo]{bar}{options={}, lab

  • infensus
    regex arguments token braces
    A token can be like this {num} or {num:2} (2 being an arg)I would like to achieve matching like this:// no args [0] = num// args (anything after the colon and before the closing brace as one match is fine) [0] = num [1] = 2I managed to match anything in the braces that was easy but my regex is too noob to get anything more complex than that! Thanks.FYI I am using javascript and \{(.*?)\} matches all the contents within.

  • kovibear
    c++ if-statement braces
    Alright, so I’m in the process of learning C++, and I’ve hit a strange effect while working with one of the tutorials, and I don’t quite get while it’s happening..For the tutorial (copied from the example offered), I have written a function within a class template specialization that checks if the char is lowercase, and then makes it uppercase:char uppercase () {//checks to see if “element”(char) is a lower-case letter between ‘a’ and ‘z’if ((element >= ‘a’) && (element <= ‘z’)){//

Web site is in building

I discovery a place to host code、demo、 blog and websites.
Site access is fast but not money