If you have variables defined in your gradle.properties
file, when is it necessary to use curly braces for variable substitution (e.g., "some string ${yourVariable}"
) and when is it okay to do without (e.g., "some string $yourVariable"
). Is it considered best practice to always use curly braces?
Asked
Active
Viewed 6,108 times
10

Opal
- 81,889
- 28
- 189
- 210

Michael Wu
- 1,177
- 1
- 13
- 34
1 Answers
13
Is it considered best practice to always use curly braces?
Not necessarily. You can use curly braces all the time for consistency but I personally use them only when necessary.
Basically if any operation or method invocation is performed in interpolated expression you need to use curly braces. In all other cases it should just work. .
operator also doesn't require to use curly braces unless you navigate the properties.
It would be much easier to view the docs. What's also important it's that it's rather groovy question, not gradle.

Opal
- 81,889
- 28
- 189
- 210
-
1Looks like I was looking in the wrong place. Thanks! – Michael Wu Nov 24 '15 at 19:03