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 - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -