A list of puns related to "Curly Braces"
I understand that '=' operator canby default sometimes lead to unwanted data-narrowing, which can be avoided by using {} syntax instead.
However, when compiling code with /W4 and /WX, any such occasion would AFAIK throw compiller error anyway, wouldn't it?
So is there any benefit of using syntax as:
bool x{true};
int i{0};
compared to the older (but IMHO more readable):
bool x = true;
int i = 0;
I've tried to find the answer, but every discussion seems to only consider default behavior without the level-4 warnings enabled.
I've used Python for many years, and am quite subjective in my view that curly braces and semicolons are unnecessary when you can do without them. Code seems more readable that way. Now, I understand that C++ has its own history and syntax choices made a long time ago but I was surprised to learn that a more "recent" language Rust also uses this type of syntax.
Please help me understand or link any good sources: are there technical or non-technical reasons why curly braces and semicolons would be preferred over say newlines and indentation? (apart from being able to format source code like a donut) Could one, hypothetically, reimplement say Rust language with just changing semicolons to newlines?
Hi,
I wonder how I can wrap curly braces around a block of code efficiently. For example, in the situation below,
https://preview.redd.it/l85ls7h4sp781.png?width=372&format=png&auto=webp&s=4aa1196d291f866e3a88e076e465ab7704b73b59
I want to insert curly braces like this:
https://preview.redd.it/xpxo5labsp781.png?width=418&format=png&auto=webp&s=f5142d12d0f26f01abb3ba04ca252fb2a2d0327d
However, when I try to insert the closing bracket, if there is another closing bracket below, vim will jump to that bracket instead of inserting a new one:
https://preview.redd.it/zn0aqetksp781.png?width=468&format=png&auto=webp&s=ae3bcc07f93f115ffe6b790867ebd66a2f2e945e
I've done some research online and found no satisfying result. Can anyone provide a solution? Thanks a lot! Merry Christmas :D
int main(void)
{
// something
{
int tmp;
// using tmp
}
// something
}
All I need is the ability to hide the name tmp. I expect the compiler to simply move all the declaration at the beginning of the function. And use name mangling for preventing access to tmp outside the scope. Is this not true? Does this have any runtime performance cost if used a lot in a single function?
Hello! A few days ago i talked about the formatting of the curly braces in C# with my teacher.
as you know there are the following two possibilities:
if (condition)
{
DoSomething();
//I know one lined If-statements don't need braces. . .
}
if (condition) {
DoSomething();
//I know one lined If-statements don't need braces. . .
}
Both work. The "auto format" tool of our IDE (SharpDevelop) formats it like the second example but my teacher says the first one is better.
What do you think? Which do you use?
Folks, I come to you with the tail between my legs .... I have been banging my head against the wall for quite a while.I am modifying a very simple script which dumps user account related info from Azure. One of the columns contains curly braces (which should get exported into the csv file). Out-GridView displays the "Licenseinfo" column (the column contains curly braces {} ) just fine and the CSV file contains the system related abracadabra.
Ideas?
************************************************************
Write-Host "Finding Azure Active Directory Accounts..."
$Users = Get-MsolUser -All | ? { $_.UserType -ne "Guest" }
$Report = [System.Collections.Generic.List[Object]]::new() # Create output file
Write-Host "Processing" $Users.Count "accounts..."
ForEach ($User in $Users) {
$MFAEnforced = $User.StrongAuthenticationRequirements.State
$MFAPhone = $User.StrongAuthenticationUserDetails.PhoneNumber
$islicensed = $User.islicensed
$Licensed = $User.Licenses
$BlockCredential = $User.BlockCredential
$WhenCreated = $User.WhenCreated
$LastPasswordChangeTimestamp = $User.LastPasswordChangeTimestamp
$DefaultMFAMethod = ($User.StrongAuthenticationMethods | ? { $_.IsDefault -eq "True" }).MethodType
If (($MFAEnforced -eq "Enforced") -or ($MFAEnforced -eq "Enabled")) {
Switch ($DefaultMFAMethod) {
"OneWaySMS" { $MethodUsed = "One-way SMS" }
"TwoWayVoiceMobile" { $MethodUsed = "Phone call verification" }
"PhoneAppOTP" { $MethodUsed = "Hardware token or authenticator app" }
"PhoneAppNotification" { $MethodUsed = "Authenticator app" }
}
}
Else {
$MFAEnforced = "Not Enabled"
$MethodUsed = "MFA Not Used"
}
$ReportLine = [PSCustomObject] @{
User = $User.UserPrincipalName
Name = $User.DisplayName
MFAUsed = $MFAEnforced
MFAMethod = $MethodUsed
PhoneNumber = $MFAPhone
BlockCredential = $BlockCredential
Licensed = $islicensed
LicenseInfo = $Licensed
WhenCreated = $WhenCreated
LastPasswordChangeTimestamp = $LastPasswordChangeTimestamp
}
$Report.Add($ReportLine)
}
W
... keep reading on reddit β‘Trying out Svelte and on:click
event.
VScode offers autocomplete on:click
but it writes doble quotes instead of curly braces: https://i.imgur.com/nLYBT3M.png
Why is that and how to make it curly braces?
Edit. Allman style!!!!
regex flavor: JavaScript
Using regex vs splitting isn't my decision, see bottom for background.
Noting matched strings are effectively \S
:
.fizz { .foo .bar } .buzz
should match foo
, bar
, not .foo
,.bar
not including fizz
/buzz
,
fizz{.foo .bar}buzz
also matches foo
, bar
{.foo.bar}
should match foo.bar
Split lines are malformed input / user error: (preview is showing this on one line, unformatted, no matter what i try...)
{ .fizz .buzz }
BUT could match fizz
. So, [}|\n|\r]
as a closing delimiter ? Not a priority.
{.fizz.bu{}zz}
Indeterminate output / stack overflow / out of memory / BSOD is OK.
One of many, many attempts: https://regex101.com/r/3s9GQL/1
I was going to include some of my steps/reasoning, but even as i type things out i have so many 'what if' ideas and noting what may or may not be flaws - this post would be a novel. (One such thing i've noticed since pasting the link: combining multiline/begin+end anchors with .* at each end of the regex.)
I've spent a couple hours a day over the past week trying new things each time but what can i say, i suck at regex. I understand the visualizations on regexr/regex101, mostly grasp the cheat-sheets and basic howtos. Nontrivial howtos with visualizations (vs just a wall of text) is something i haven't come across...
Any help/tips appreciated !
Background/Context:
Using the Generic Attributes extension for .NET's Markdown library, Markdig, we can attach ids, classes, etc, to elements. For instance:
# Heading { .text-blue-500 .italic .hover:bg-[#deadbeef] }
becomes
<h1 class="text-blue-500 italic hover:bg-[#deadbeef]">Heading</h1>
https://github.com/xoofx/markdig/blob/master/src/Markdig.Tests/Specs/GenericAttributesSpecs.md
Tailwind CSS lets us specify a regex to be used for extracting class names for a given filetype:
https://tailwindcss.com/docs/content-configuration#customizing-extraction-logic
Using the default extraction regex picks up on some, but not all of the classes specified presumably because of the leading '.'.
Above the linked section it is mentioned that "it often makes sense to compile that content to HTML before scanning it for class names" but my project is using Markdig to render markdown in-browser for local development. (Embedding converted HTML when deployed.) Taking advantage of custom extraction logi
... keep reading on reddit β‘`paperless-ng` has a configuration file that is not used in Docker mode; instead, the parameters need to be provided as docker environment variables. So far so good! Except that one parameter requires curly braces.
Curly braces are part of the YAML syntax, so to use them inside a value of a Docker environment variable, these braces need to be escaped. Below is a simplified part of the Docker compose that I have in Portainer. The whole thing works fine except that the last line below is plainly ignored. (In the actual file, there are more lines after.)
--> How can I escape the curly braces in the last line?
services:
database:
foo: bar
blah: baz
webserver:
image: jonaswinkler/paperless-ng
depends_on:
- database
ports:
- 12345:80
volumes:
- /foo:/bar
environment:
PAPERLESS_FOO: bar
PAPERLESS_LANGUAGE: eng
PAPERLESS_FILENAME_FORMAT: "{created_year}/{correspondent}/{title}"
I have seen sometimes that some people write commands inside curly braces
{ command one; comands two } | command
what does it do anyway?
Should i trade Polar Star?
I made a very simple #define macro in C with curly braces inside parentheses, and even though the compiler doesn't give any errors or warnings, even with all warning flags turned on, vim still decides that the braces should be highlighted in red. Below I have pasted the code in question.
#define vectorFromComponents(x, y) ((Vector) { \
x, \
y, \
hypot(x, y), \
atan2(y, x) \
})
I'm planning to jump into godot4, I have played with the engine previously, I found the lack of curly braces made looking at function scope and logic nesting to be a bit cumbersome. Is there a way I can use gdscript and still have my curly braces? gdscript is somehow related to python right? Curly braces are optional in python?
Either way, I welcome any and all editor tweaks I could do to help with code formatting and comprehension.
Cheers.
So the code where the issue occurs looks like:
<a href="{{ url_for('download_file', filename='{{original_filename}}_{{loop.index}}.jpg') }}">
The issue is that it's processing the inner curly braces as literal curly braces, not as Jinja syntax. How do I avoid this? How do I put Jinja variables inside of a Jinja variable?
Hi, I'm still new to laravel, I am just wondering what data is being pulled and from where when using the double curly braces.. if I have a {{ $variable }} within example.blade.php, where would this $variable be within the laravel file? I remember an instance of using a variable from a model I believe but I can't be sure. Any help would be appreciated.
i am working on C++ source that uses no indentation for C++ namespace. is there a way to add a comment in the file to tell emacs that at that particular line it should assume the indentation level to be at zero or to ignore specifically marked curly braces?
i do not want to configure namespace indentation in general and i do not want to know how to do it (non-portable) with the help of lisp in my own configuration file.
is there magic which can be added in comments to affect indentation on the fly?
New to Haskell and going through tutorials, trying to understand how Haskell knows where functions begin and end witgout braces.
Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.