I can understand what is Closures. i can understand below example.
def list = ['a','b','c','d']
def newList = []
def clos = { it.toUpperCase() }
list.collect( newList, clos )
assert newList == ["A", "B", "C", "D"]
I went to see g:select documentation. i saw below.
<g:select optionKey="id" optionValue="${{it.title?.toUpperCase()}}" name="book.title" from="${bookList}" />
I did’t understand ${{it.title?.toUpperCase()}}.
i understand the logic that for each object title is converted to uppercase, but why we need double “{}”..
why it did not work using ${it.title?.toUpperCase()}
documentation link enter link description here
The outher ${ } is not a closure, is a GSP Expression, only the inner {} is a closure. If you put only ${it.title?.toUpperCase()} you don’t pass the parameter a closure but the actual “it.title?.toUpperCase()” resolved value.