java - Notation of the Dynamic Querying Associations -


in latest documentation of grails, can read:

querying associations. associations can used within queries:

def author = author.findbyname("stephen king")  def books = author ? book.findallbyauthor(author) : [] 

i'd know meaning of ? , : []

shorthand if statement in groovy (and java, see first comment).

def books = author ? book.findallbyauthor(author) : [] 

is equivalent of:

def books if (author) {     books = book.findallbyauthor(author) } else {     books = [] } 

see elvis operator (groovy only, not java) here.


Comments

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -