Two type declarations for a single variable in Groovy? -
while reading tutorial on gradle plugins, cam across following code:
apply plugin: greetingplugin greeting.message = 'hi gradle' class greetingplugin implements plugin<project> { void apply(project project) { // add 'greeting' extension object project.extensions.create("greeting", greetingpluginextension) // add task uses configuration project.task('hello') << { println project.greeting.message } } } class greetingpluginextension { def string message = 'hello greetingplugin' }
my understanding line def string message = 'hello greetingplugin'
declaring 2 types (both generic def
type , specific string
type). removing either of types seems allow script continue execute.
is there reason why groovy allows 2 type declarations made single variable? if so, use cases language feature , serve specific purpose in situation?
the line
def string message = 'hello greetingplugin'
is wrong. def
waste of characters in situation doesn't anything
that line same as
string message = 'hello greetingplugin'
Comments
Post a Comment