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

Cannot define a no-args closure in Groovy Shell

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.1.6, 2.2.0-beta-1
    • 2.1.7, 2.2.0-beta-2
    • Groovysh
    • None

    Description

      1. I wanted to define this very simple no-args closure, foo, using groovysh:

      def foo = { ->
              println "test"
      }
      

      2. But the moment I hit ENTER in the shell after typing out the first line,
      I get the following error:

      $ groovysh
      Groovy Shell (2.1.5, JVM: 1.6.0_43)
      Type 'help' or '\h' for help.
      -----------------------------------------------------------------------------------
      groovy:000> def foo = { ->
      ERROR org.codehaus.groovy.control.MultipleCompilationErrorsException:
      startup failed:
      groovysh_parse: 2: unexpected token: -> @ line 2, column 13.
      def foo = { ->
      ^
      1 error
      at java_lang_Runnable$run.call (Unknown Source)

      source: http://groovy.329449.n5.nabble.com/groovysh-bug-Cannot-define-a-no-args-closure-which-I-can-define-outside-of-it-td5716267.html

      Attachments

        Activity

          People

            pschumacher Pascal Schumacher
            pschumacher Pascal Schumacher
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: