groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guy Matz <guym...@gmail.com>
Subject Groovy defaults method argument to null?
Date Tue, 03 May 2016 19:58:08 GMT
I have a method that starts like this:

class Sidecar {

  def static String getVersions(String render_server) {

    def rest = new RESTClient('http://' + render_server)

    try {

      def vpath = *'*/r/api/versions'
      log.debug "Hitting http://${render_server}${vpath}"
      def resp = rest.get(path:vpath)


and when I call it as Sidecar.getVersions('server-name') it works as
expected.  When I "accidentally" call it without a parameter, though,
Groovy does not complain until it attempts the REST call:

groovy:000> r = Sidecar.getVersions()

15:49:41.209 [main] DEBUG com.jcrew.jenkins.helpers.Sidecar - Hitting
http://*null*/r/api/versions


Is Groovy defaulting the parameter to null when it's not supplied?

Mime
View raw message