0

I am new to dynamic languages and now learning groovy & grails. I am little bit confused on how to write controller actions. In examples, i see two ways of writing actions:

1.
def action(args) {
    // do some action and render the result
}

2.
def action = { 
   // do some action
}

Can anyone explain what is the difference between these two syntax's

rags
  • 2,580
  • 19
  • 37
ikvenu2000
  • 331
  • 1
  • 3
  • 13

1 Answers1

1

The first is a method, the second is a closure.

Since grails 2, you want to be doing methods in controllers

Why should grails actions be declared as methods instead of closures and what difference does it make?

Community
  • 1
  • 1
tim_yates
  • 167,322
  • 27
  • 342
  • 338