Skip to content

What I Learned Today: Groovy Default Parameter Goodness

Default parameters can reference other parameters.

This little snippet of Groovy:

def f(x, y = x) {
  println "x=$x, y=$y"
}

f('hello', 'world')
f('hi')

Gives:

x=hello, y=world
x=hi, y=hi

Tags: ,

C, Java Enterprise Edition, JEE, J2EE, JBoss, Application Server, Glassfish, JavaServer Pages, JSP, Tag Libraries, Servlets, Enterprise Java Beans, EJB, Java Messaging Service JMS, BEA Weblogic, JBoss, Application Servers, Spring Framework, Groovy, Grails, Griffon, GPars, GAnt, Spock, Gradle, Seam, Open Source, Service Oriented Architectures, SOA, Java 2 Standard Edition, J2SE, Eclipse, Intellij, Oracle Service Bus, OSB