This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Groovy and the fly likes Implement interfaces with a closure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Languages » Groovy
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: 28
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implement interfaces with a closure