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

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

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

javascript - Chart.js - setting tooltip z-index -