I'm trying to import another class in groovy, but to no sucess so far. I've tried to run this example:
http://www.chatsiri.com/?q=node/163
开发者_高级运维didn't work.
Caught: groovy.lang.MissingPropertyException: No such property: readData
There is a lot of typos in the Code, and it does not follow the Convention for the java classes like (and the article is from 2007):
- Class instead of class
- Class name starting with lowercase
- printIn? instead of println
- System.In.readString()??? Not in the actual Groovy JDK
Anyways, just creating new classes Foo and Bar to corraborate what the blog is saying.....
File Bar.groovy
class Bar{
def print(){
println "Bar"
}
def add(a, b){
return a+b;
}
}
File Foo.groovy
def b = new Bar()
b.print()
println b.add(1,2)
Runing
>groovy Foo.groovy
Bar
3
精彩评论