When do you need curly braces for variable substitution in Gradle?
Asked Answered
E

1

12

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?

Eggshaped answered 23/11, 2015 at 20:36 Comment(0)
H
15

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.

Huxham answered 24/11, 2015 at 8:27 Comment(1)
Looks like I was looking in the wrong place. Thanks!Eggshaped

© 2022 - 2024 — McMap. All rights reserved.