jaspal
jaspal

Reputation: 37

how to call Parameter-Less method in Groovy without braces

i can call method with parameter without braces example:- for def method(args){}

we can call it like
method " parameter"

but what if method does not have any parameter void method()

how to call it without braces?

Upvotes: 2

Views: 2256

Answers (2)

Anton Hlinisty
Anton Hlinisty

Reputation: 1467

You can call only getters and setters without parameters.

E.g.:

getValue() {
    ...
}

may be called as

instance.value

Upvotes: 0

tim_yates
tim_yates

Reputation: 171084

You can't, you need the braces like method() as you say

Upvotes: 3

Related Questions