Advertisement
NLinker

Groovy puzzlers

May 24th, 2018
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.55 KB | None | 0 0
  1. if (true) {
  2.     def key = 'x'
  3.     def map = [key: 'treasure']
  4.     def val = map.get(key)
  5.     println val
  6. }
  7. if (true) {
  8.     def map = [2: 'treasure']
  9.     def key = 2
  10.     def val = map."$key"
  11.     println val
  12. }
  13. if (true) {
  14.     List<Long> list = [1,2,3]
  15.     def now = new Date()
  16.     list << now
  17.     println list
  18.     println list*.class.name
  19. }
  20. if (true) {
  21.     def map = [metaClass: "Frequency"]
  22.     println "What's the $map.metaClass, dude?"
  23. }
  24.  
  25. def static hello(n) {
  26.     ['9': "Hell${n}, Alex!"]
  27. }
  28. def result = hello 09
  29. println result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement