IntelliJ Java IDE
The moose likes Groovy and the fly likes Implement interfaces with a closure Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Other Languages » Groovy
Reply Bookmark "Implement interfaces with a closure" Watch "Implement interfaces with a closure" New topic
Author

Implement interfaces with a closure

Sri Yasasvi
Greenhorn

Joined: Nov 07, 2008
Posts: 27
def readable = { it.put("12 34".reverse()); 5 } as Readable

def s = new Scanner(readable)
assert s.nextInt() == 43
println s.nextInt()


As of my understanding, the above code snippet should print 21. But it is printing 2143. Could anyone of you explain this please.

Thanks,
Yasasvi
 
 
subject: Implement interfaces with a closure
 
Threads others viewed
Scala exercises for beginners (in FP)
creating an update class for program
Rails uptake time?
How Tomcat Works book - reader question
Clousers in Groovy
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com