Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10072

SC: closure with default argument(s)

    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      @groovy.transform.CompileStatic
      void test() {
        def c = { p = 'foo' -> return p }
        assert c('bar') == 'bar'
        assert c() == 'foo'
      
        c = { p, q = 'baz' -> return '' + p + q }
        assert c('foo', 'bar') == 'foobar'
        assert c('foo') == 'foobaz'
      }
      test()
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              emilles Eric Milles
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: