red888
red888

Reputation: 31550

How do nested expressions work in groovy?

Right now I'm doing this:

// Returns a string that needs to be manipulated
def str = callSomeFunc arg1:'sdfsdf', arg2:'blah', arg3:'sdfs'
str = str.trim()

Because this doesn't work:

def str = (callSomeFunc arg1:'sdfsdf', arg2:'blah', arg3:'sdfs').trim()

Upvotes: 1

Views: 96

Answers (1)

Opal
Opal

Reputation: 84756

Have a look at the docs:

In some cases parentheses are required, such as when making nested method calls or when calling a method without parameters.

In your case this will work also:

def str = callSomeFunc(arg1:'sdfsdf', arg2:'blah', arg3:'sdfs').trim()

Upvotes: 2

Related Questions