[groovy-user] String.eachLine()

373 views
Skip to first unread message

Todd Wells

unread,
Dec 11, 2008, 3:34:55 PM12/11/08
to us...@groovy.codehaus.org
Does String.eachLine() work? I must be doing something dumb, hopefully someone can point out what it is:

      void testEachLine() {
        def foo = """
            blah blah
            foo foo
            hey hey
        """

        foo.eachLine {
            println it
        }
    }


Fails with:

groovy.lang.MissingMethodException: No signature of method: java.lang.String.eachLine() is applicable for argument types: (BreakAtThresholdTest$_testEachLine_closure1) values: {BreakAtThresholdTest$_testEachLine_closure1@f11507}
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:169)
    at BreakAtThresholdTest.testEachLine(BreakAtThresholdTest.groovy:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)


Jim White

unread,
Dec 11, 2008, 3:40:17 PM12/11/08
to us...@groovy.codehaus.org
Works for me (1.5 and trunk). Perhaps something is borked in your install.

Jim

Todd Wells wrote:
> Does String.eachLine()
> <http://groovy.codehaus.org/groovy-jdk/java/lang/String.html#eachLine%28int%20firstLine,%20groovy.lang.Closure%20closure%29>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Todd Wells

unread,
Dec 11, 2008, 3:46:07 PM12/11/08
to us...@groovy.codehaus.org
I'm using grails 1.0.2 which uses groovy 1.5.4.  When I do it in groovysh with 1.5.6, it works.  Was eachLine() introduced post-1.5.4?

Jim White

unread,
Dec 11, 2008, 4:04:09 PM12/11/08
to us...@groovy.codehaus.org
Todd Wells wrote:

> I'm using grails 1.0.2 which uses groovy 1.5.4. <http://1.5.4.> When I

> do it in groovysh with 1.5.6, it works. Was eachLine() introduced
> post-1.5.4?

Yes indeed. Tracked it down to 1.5.5.

Jim

Reply all
Reply to author
Forward
0 new messages