anish
anish

Reputation: 7412

overloading dot "." with plus "+" in groovy dsl

how to overload the . operator with + operator in groovy. for example i have to build the DSL somethong like this:

model+make+version instead of model.make.version

how to build the dsl using + any example or hint

Upvotes: 2

Views: 562

Answers (1)

Nikita Volkov
Nikita Volkov

Reputation: 43320

You can't overload the ., you can overload a +. model+make+version+"2" actually evaluates to model.plus(make.plus(version.plus("2"))). Providing plus methods on those objects will do the trick, but the whole idea just seems ridiculous.

Upvotes: 2

Related Questions