Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def x = 0
- def y = 5
- while ( y-- > 0 ) {
- println "" + x + " " + y
- x++
- }
- assert x == 5
- x = 1
- assert x == 1
- assert this.binding.getVariable("x") == 1
- def y = 2
- assert y == 2
- try {
- this.binding.getVariable("y")
- } catch (groovy.lang.MissingPropertyException e) {
- println "error caught"
- }
- x = 1
- def y = 2
- public bar() {
- assert x == 1
- try {
- assert y == 2
- } catch (groovy.lang.MissingPropertyException e) {
- println "error caught"
- }
- }
- bar()
- // Groovy imports java.io.* and java.util.* automatically
- // but not java.nio.*
- import java.nio.channels.*
- class Foo {
- public void bar() {
- FileChannel channel = new FileInputStream('Test.groovy').getChannel()
- println channel.toString()
- }
- }
- new Foo().bar()
- // Groovy imports java.io.* and java.util.* automatically
- // but not java.nio.*
- class Foo {
- public void bar() {
- def channel = new FileInputStream('Test.groovy').getChannel()
- println channel.toString()
- }
- }
- new Foo().bar()
Add Comment
Please, Sign In to add comment