Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Style Guide: AVOID bracketed interpolation of simple identifiers. #1239

Closed
seaneagan opened this issue Feb 5, 2015 · 8 comments
Closed

Style Guide: AVOID bracketed interpolation of simple identifiers. #1239

seaneagan opened this issue Feb 5, 2015 · 8 comments

Comments

@seaneagan
Copy link

If it's in the linter:

https://github.com/dart-lang/dart_lint/issues/3

seems like it should then also be in the style guide:

AVOID bracketed interpolation of simple identifiers.

bad

print("Hi, ${name}!");

good

"Hi, $name!"
@seaneagan
Copy link
Author

Should also mention that it's OK when followed by alpha numerics:

good

print('\$${dollars}USD');

@pq
Copy link
Contributor

pq commented Feb 5, 2015

I'll leave to other's on the style council to deem whether this is style guide worthy (ahem @munificent) but I should chime in on this point:

If it's in the linter ... seems like it should then also be in the style guide

I would turn it around actually:

if it's in the style guide it should be in the linter

My thinking is that the linter will certainly provide rules that transcend the guide. Indeed it may even have rules that contradict it (or certainly rules that are mutually incompatible with each other). Having said that, there should certainly be a Rule SET provided by the linter that is complete agreement with the guide.

@munificent
Copy link
Contributor

👍 for having this in the style guide. I would say:

AVOID using braces in interpolation when not needed. If you're just interpolating a simple identifier, and it's not immediately followed by more alphanumeric text, the {} can and should be omitted.

@pq
Copy link
Contributor

pq commented Feb 10, 2015

Awesome. Where do we go from here? Does @kwalrath own changes or is a pull request welcome?

@kwalrath
Copy link
Contributor

Either one is fine, but I can take care of this one.

@kwalrath kwalrath self-assigned this Feb 10, 2015
@pq
Copy link
Contributor

pq commented Feb 10, 2015

👍 Thanks @kwalrath!

@kwalrath
Copy link
Contributor

@munificent
Copy link
Contributor

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

4 participants