• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implement interfaces with a closure

 
Sri Yasasvi
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic