SlideShare a Scribd company logo
1 of 146
1. Two entertaining guys on stage 
2. Funny Puzzling questions 
3. You think and vote 
4. Lots of T-shirts flying in the air 
5. Official twitter handle! 
groovypuzzlers
Cédric?!
class Conference {def name; def year} 
def gr = new Conference(name: 'Greach', year: 2014) 
gr.each {println it}
-3.abs()
(-3).abs() 
int value = -3 
value.abs()
println (-3).abs()
println (-3).abs() 
-3 
Caught: java.lang.NullPointerException: Cannot invoke method abs() on null 
object 
java.lang.NullPointerException: Cannot invoke method abs() on null object 
at AbsolutelyGroovy.run(AbsolutelyGroovy.groovy:7) 
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
“All problems in computer science can be 
solved by another pair of parentheses” 
John McCarthy, the inventor of LISP
println ((-3).abs()) 
int value = -3 
println value.abs()
def x = int 
println x 
if ((x = long)) { 
println x 
} 
if (x = boolean ) { 
println x 
}
def x = int 
println x 
if ((x = long)) { 
println x 
} 
if (x = boolean ) { 
println x 
}
Closure whodunit() { 
{ 
'The butler did it.' 
} 
} 
println whodunit()
Closure whodunit() { 
{ -> 
'The butler did it.' 
} 
}
PUBLIC - 
PROPERTY!
trait Public { 
public String property = "I am all public!" 
} 
class Property implements Public {} 
Property publicProperty = new Property()
trait Public { 
public String property = "I am all public!" 
} 
class Property implements Public {} 
Property publicProperty = new Property()
http://beta.groovy-lang. 
org/docs/groovy- 
2.3.0/html/documentation/core-
def range = 1.0..10.0 
assert range.contains(5.0) 
println range.contains(5.6)
Iterator iterator = (1.0..10.0).iterator() 
while (iterator.hasNext()) { 
print "${iterator.next()} " 
} 
1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0
[0..9].each { println(it - 1) }
def key = 'x' 
def map = [key: 'treasure'] 
def value = map.get(key) 
println value
def key = 'x' 
def map = [key: 'treasure'] 
def value = map.get(key) 
println value
1.def map = [(key): 'treasure'] 
2.map.put(key, 'treasure') 
3.map."$key" = 'treasure' 
4.map[key] = 'treasure'
def map = [2: 'treasure'] 
def key = 2 
def value = map."$key" 
println value
def map = [2: 'treasure'] 
def key = 2 
def value = map."$key" 
println value
def map = [2: 'treasure'] 
println map.keySet().first().class.name 
java.lang.Integer
List<Long> list = [1,2,3] 
def now = new Date() 
list << now 
println list
List<Long> list = [1,2,3] 
def now = new Date() 
list << now 
println list
List<Long> list = [1,2,3] 
def now = new Date() 
list << now 
list << 'foo' 
println list*.class.name 
[java.lang.Long, java.lang.Long, 
java.lang.Long, java.util.Date, 
java.lang.String]
def map = [metaClass: ‘frequency'] 
println "What's the $map.metaClass, Baruch?"
map.metaClass 
map.get('metaClass') 
map.getMetaClass()
boolean isPrime(def x) { 
if (x == 2) return true 
int limit = Math.sqrt(x) + 1 
(2..limit).each { 
if (x % it == 0) { 
return false 
} 
} 
true 
} 
println isPrime("4" as Double)
boolean isPrime(def x) { 
if (x == 2) return true 
int limit = Math.sqrt(x) + 1 
(2..limit).each { 
if (x % it == 0) { 
return false 
} 
} 
true 
} 
println isPrime("4" as Double)
boolean isPrime(def x) { 
if (x == 2) return true 
int limit = Math.sqrt(x) + 1 
(2..limit).each { 
if (x % it == 0) { 
return false 
} 
} 
true 
} 
println isPrime("4" as Double)
http://kousenit.wordpress.com/2014/04/18/response 
s-to-the-closure-of-no-return/
class VanHalen { 
public static jump() { 
"Here are the ${lyrics()}" 
} 
def methodMissing(String name, def args) { 
'lyrics' 
} 
} 
println VanHalen.jump()
class VanHalen { 
public static jump() { 
"Here are the ${lyrics()}" 
} 
def methodMissing(String name, def args) { 
'lyrics' 
} 
} 
println VanHalen.jump()
class VanHalen { 
public static jump() { 
"Here are the ${lyrics()}" 
} 
static $static_methodMissing(String name, def args) { 
'lyrics' 
} 
} 
println VanHalen.jump()
class VanHalen { 
public jump() { 
"Here are the ${lyrics()}" 
} 
def methodMissing(String name, def args) { 
'lyrics' 
} 
} 
println new VanHalen().jump()
double value = 3 
println "$value.14".isDouble()
double value = 3 
println "$value.14".isDouble()
class Invite { 
int attending = 1 
} 
def invite = new Invite() 
def attendees = (invite.attending) +1 
println attendees
class Invite { 
int attending = 1 
} 
def invite = new Invite() 
def attendees = (invite.attending) +1 
println attendees
def attendees = (new Invite().attending) + 1 
println attendees 
def invite = new Invite() 
println (invite.attending +1)
1. Write readable code 
2. Comment neat tricks 
3. Sometimes it is just a bug 
4. Use static code analysis (intellij IDEA!) 
5. Rtfm 
6. Don’t code like my brother
We have just started! 
(may end up in proper uniform) 
Puzzlers? Gotchas? 
- puzzlers jfrog.com 
- Groovypuzzlers
Positive feedback? 
Praise us on twitter 
groovypuzzlers 
- Groovypuzzlers 
- _yoav_ 
- jbaruch 
Negative feeдback? 
> /dev/null
The groovy puzzlers (as Presented at JavaOne 2014)

More Related Content

What's hot

Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxEleanor McHugh
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveEleanor McHugh
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1Ke Wei Louis
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackVic Metcalfe
 
Taking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order FunctionsTaking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order FunctionsDavid Golden
 
dplyr and torrents from cpasbien
dplyr and torrents from cpasbiendplyr and torrents from cpasbien
dplyr and torrents from cpasbienRomain Francois
 
Communities - Perl edition (RioJS)
Communities - Perl edition (RioJS)Communities - Perl edition (RioJS)
Communities - Perl edition (RioJS)garux
 
Closures
ClosuresClosures
ClosuresSV.CO
 
Exploring slides
Exploring slidesExploring slides
Exploring slidesakaptur
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and GoEleanor McHugh
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2osfameron
 
How fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practiceHow fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practiceTobias Pfeiffer
 
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...akaptur
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?osfameron
 
Extending Operators in Perl with Operator::Util
Extending Operators in Perl with Operator::UtilExtending Operators in Perl with Operator::Util
Extending Operators in Perl with Operator::UtilNova Patch
 
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonByterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonakaptur
 

What's hot (20)

Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Py3k
Py3kPy3k
Py3k
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's Perspective
 
Clang2018 class3
Clang2018 class3Clang2018 class3
Clang2018 class3
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: Hack
 
Taking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order FunctionsTaking Perl to Eleven with Higher-Order Functions
Taking Perl to Eleven with Higher-Order Functions
 
Lập trình Python cơ bản
Lập trình Python cơ bảnLập trình Python cơ bản
Lập trình Python cơ bản
 
dplyr and torrents from cpasbien
dplyr and torrents from cpasbiendplyr and torrents from cpasbien
dplyr and torrents from cpasbien
 
Communities - Perl edition (RioJS)
Communities - Perl edition (RioJS)Communities - Perl edition (RioJS)
Communities - Perl edition (RioJS)
 
Closures
ClosuresClosures
Closures
 
Exploring slides
Exploring slidesExploring slides
Exploring slides
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
 
Codigos
CodigosCodigos
Codigos
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2
 
How fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practiceHow fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practice
 
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
Allison Kaptur: Bytes in the Machine: Inside the CPython interpreter, PyGotha...
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
 
Extending Operators in Perl with Operator::Util
Extending Operators in Perl with Operator::UtilExtending Operators in Perl with Operator::Util
Extending Operators in Perl with Operator::Util
 
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonByterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
 

Similar to The groovy puzzlers (as Presented at JavaOne 2014)

The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsBaruch Sadogursky
 
Scala in a Java 8 World
Scala in a Java 8 WorldScala in a Java 8 World
Scala in a Java 8 WorldDaniel Blyth
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기JangHyuk You
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with GroovyArturo Herrero
 
Swift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdfSwift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdfJkPoppy
 
여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala LanguageAshal aka JOKER
 
An Introduction to Scala (2014)
An Introduction to Scala (2014)An Introduction to Scala (2014)
An Introduction to Scala (2014)William Narmontas
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingMuthu Vinayagam
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScriptniklal
 
Monadologie
MonadologieMonadologie
Monadologieleague
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecLoïc Descotte
 
The Future of JVM Languages
The Future of JVM Languages The Future of JVM Languages
The Future of JVM Languages VictorSzoltysek
 
Laziness in Swift
Laziness in Swift Laziness in Swift
Laziness in Swift SwiftWro
 

Similar to The groovy puzzlers (as Presented at JavaOne 2014) (20)

The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 Seasons
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Scala in a Java 8 World
Scala in a Java 8 WorldScala in a Java 8 World
Scala in a Java 8 World
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
ddd+scala
ddd+scaladdd+scala
ddd+scala
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with Groovy
 
Swift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdfSwift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdf
 
여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language
 
An Introduction to Scala (2014)
An Introduction to Scala (2014)An Introduction to Scala (2014)
An Introduction to Scala (2014)
 
Php functions
Php functionsPhp functions
Php functions
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScript
 
Monadologie
MonadologieMonadologie
Monadologie
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
 
Java VS Python
Java VS PythonJava VS Python
Java VS Python
 
The Future of JVM Languages
The Future of JVM Languages The Future of JVM Languages
The Future of JVM Languages
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
What's New In C# 7
What's New In C# 7What's New In C# 7
What's New In C# 7
 
Laziness in Swift
Laziness in Swift Laziness in Swift
Laziness in Swift
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

The groovy puzzlers (as Presented at JavaOne 2014)

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. 1. Two entertaining guys on stage 2. Funny Puzzling questions 3. You think and vote 4. Lots of T-shirts flying in the air 5. Official twitter handle! groovypuzzlers
  • 11.
  • 13.
  • 14.
  • 15.
  • 16. class Conference {def name; def year} def gr = new Conference(name: 'Greach', year: 2014) gr.each {println it}
  • 17.
  • 18.
  • 19.
  • 21.
  • 22. (-3).abs() int value = -3 value.abs()
  • 23.
  • 25.
  • 26.
  • 27. println (-3).abs() -3 Caught: java.lang.NullPointerException: Cannot invoke method abs() on null object java.lang.NullPointerException: Cannot invoke method abs() on null object at AbsolutelyGroovy.run(AbsolutelyGroovy.groovy:7) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
  • 28. “All problems in computer science can be solved by another pair of parentheses” John McCarthy, the inventor of LISP
  • 29. println ((-3).abs()) int value = -3 println value.abs()
  • 30.
  • 31.
  • 32. def x = int println x if ((x = long)) { println x } if (x = boolean ) { println x }
  • 33. def x = int println x if ((x = long)) { println x } if (x = boolean ) { println x }
  • 34.
  • 35.
  • 36.
  • 37.
  • 38. Closure whodunit() { { 'The butler did it.' } } println whodunit()
  • 39.
  • 40.
  • 41. Closure whodunit() { { -> 'The butler did it.' } }
  • 42.
  • 44. trait Public { public String property = "I am all public!" } class Property implements Public {} Property publicProperty = new Property()
  • 45. trait Public { public String property = "I am all public!" } class Property implements Public {} Property publicProperty = new Property()
  • 46.
  • 47.
  • 48.
  • 50.
  • 51. def range = 1.0..10.0 assert range.contains(5.0) println range.contains(5.6)
  • 52.
  • 53.
  • 54.
  • 55.
  • 56. Iterator iterator = (1.0..10.0).iterator() while (iterator.hasNext()) { print "${iterator.next()} " } 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73. def key = 'x' def map = [key: 'treasure'] def value = map.get(key) println value
  • 74. def key = 'x' def map = [key: 'treasure'] def value = map.get(key) println value
  • 75.
  • 76.
  • 77. 1.def map = [(key): 'treasure'] 2.map.put(key, 'treasure') 3.map."$key" = 'treasure' 4.map[key] = 'treasure'
  • 78.
  • 79. def map = [2: 'treasure'] def key = 2 def value = map."$key" println value
  • 80. def map = [2: 'treasure'] def key = 2 def value = map."$key" println value
  • 81.
  • 82. def map = [2: 'treasure'] println map.keySet().first().class.name java.lang.Integer
  • 83.
  • 84.
  • 85. List<Long> list = [1,2,3] def now = new Date() list << now println list
  • 86. List<Long> list = [1,2,3] def now = new Date() list << now println list
  • 87.
  • 88.
  • 89.
  • 90.
  • 91. List<Long> list = [1,2,3] def now = new Date() list << now list << 'foo' println list*.class.name [java.lang.Long, java.lang.Long, java.lang.Long, java.util.Date, java.lang.String]
  • 92.
  • 93.
  • 94. def map = [metaClass: ‘frequency'] println "What's the $map.metaClass, Baruch?"
  • 95.
  • 96.
  • 98.
  • 99.
  • 100.
  • 101. boolean isPrime(def x) { if (x == 2) return true int limit = Math.sqrt(x) + 1 (2..limit).each { if (x % it == 0) { return false } } true } println isPrime("4" as Double)
  • 102.
  • 103. boolean isPrime(def x) { if (x == 2) return true int limit = Math.sqrt(x) + 1 (2..limit).each { if (x % it == 0) { return false } } true } println isPrime("4" as Double)
  • 104. boolean isPrime(def x) { if (x == 2) return true int limit = Math.sqrt(x) + 1 (2..limit).each { if (x % it == 0) { return false } } true } println isPrime("4" as Double)
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 112.
  • 113.
  • 114. class VanHalen { public static jump() { "Here are the ${lyrics()}" } def methodMissing(String name, def args) { 'lyrics' } } println VanHalen.jump()
  • 115. class VanHalen { public static jump() { "Here are the ${lyrics()}" } def methodMissing(String name, def args) { 'lyrics' } } println VanHalen.jump()
  • 116.
  • 117.
  • 118.
  • 119.
  • 120. class VanHalen { public static jump() { "Here are the ${lyrics()}" } static $static_methodMissing(String name, def args) { 'lyrics' } } println VanHalen.jump()
  • 121. class VanHalen { public jump() { "Here are the ${lyrics()}" } def methodMissing(String name, def args) { 'lyrics' } } println new VanHalen().jump()
  • 122.
  • 123. double value = 3 println "$value.14".isDouble()
  • 124.
  • 125.
  • 126.
  • 127. double value = 3 println "$value.14".isDouble()
  • 128.
  • 129.
  • 130.
  • 131.
  • 132. class Invite { int attending = 1 } def invite = new Invite() def attendees = (invite.attending) +1 println attendees
  • 133. class Invite { int attending = 1 } def invite = new Invite() def attendees = (invite.attending) +1 println attendees
  • 134.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139. def attendees = (new Invite().attending) + 1 println attendees def invite = new Invite() println (invite.attending +1)
  • 140.
  • 141.
  • 142. 1. Write readable code 2. Comment neat tricks 3. Sometimes it is just a bug 4. Use static code analysis (intellij IDEA!) 5. Rtfm 6. Don’t code like my brother
  • 143. We have just started! (may end up in proper uniform) Puzzlers? Gotchas? - puzzlers jfrog.com - Groovypuzzlers
  • 144.
  • 145. Positive feedback? Praise us on twitter groovypuzzlers - Groovypuzzlers - _yoav_ - jbaruch Negative feeдback? > /dev/null

Editor's Notes

  1. CURRENT – JB NEXT - YOAV
  2. CURRENT – JB NEXT - YOAV
  3. CURRENT – JB NEXT - YOAV
  4. CURRENT – JB NEXT - YOAV
  5. CURRENT – JB NEXT - YOAV
  6. CURRENT – JB NEXT - YOAV
  7. CURRENT – JB NEXT - YOAV
  8. CURRENT – JB NEXT - YOAV 2001 OracleWorld: Joshua Bloch, Neal Gafter
  9. CURRENT – JB NEXT - YOAV The Car Show (1977-2012) Click and Clack, the Tappet Brothers - Tom and Ray Magliozzi
  10. CURRENT – YOAV NEXT - JB
  11. CURRENT – YOAV NEXT - JB
  12. CURRENT – YOAV NEXT - JB
  13. CURRENT – YOAV NEXT - JB
  14. CURRENT – YOAV NEXT - JB
  15. CURRENT – JB NEXT - YOAV
  16. CURRENT – JB NEXT - YOAV
  17. CURRENT – JB NEXT - YOAV
  18. CURRENT – JB NEXT - YOAV
  19. CURRENT – YOAV NEXT - JB
  20. CURRENT – YOAV NEXT - JB
  21. CURRENT – YOAV NEXT - JB
  22. CURRENT – YOAV NEXT - JB
  23. CURRENT – YOAV NEXT - JB
  24. CURRENT – YOAV NEXT - JB
  25. CURRENT – YOAV NEXT - JB
  26. CURRENT – YOAV NEXT - JB
  27. CURRENT – YOAV NEXT - JB
  28. CURRENT – YOAV NEXT - JB
  29. CURRENT – YOAV NEXT - JB
  30. CURRENT – YOAV NEXT - JB
  31. CURRENT – JB NEXT - YOAV
  32. CURRENT – JB NEXT - YOAV
  33. CURRENT – JB NEXT - YOAV
  34. CURRENT – JB NEXT - YOAV
  35. CURRENT – JB NEXT - YOAV
  36. CURRENT – JB NEXT - YOAV
  37. CURRENT – YOAV NEXT - JB
  38. CURRENT – YOAV NEXT - JB
  39. CURRENT – YOAV NEXT - JB
  40. CURRENT – YOAV NEXT - JB
  41. CURRENT – YOAV NEXT - JB
  42. CURRENT – YOAV NEXT - JB
  43. CURRENT – JB NEXT – YOAV
  44. CURRENT – JB NEXT – YOAV
  45. CURRENT – JB NEXT – YOAV
  46. CURRENT – JB NEXT – YOAV
  47. CURRENT – JB NEXT – YOAV
  48. CURRENT – JB NEXT – YOAV
  49. CURRENT – JB NEXT – YOAV
  50. CURRENT – YOAV NEXT - YOAV
  51. CURRENT – YOAV NEXT - YOAV
  52. CURRENT – YOAV NEXT - YOAV
  53. CURRENT – YOAV NEXT - YOAV
  54. CURRENT – YOAV NEXT - YOAV
  55. CURRENT – YOAV NEXT - YOAV
  56. CURRENT – YOAV NEXT - YOAV
  57. CURRENT – YOAV NEXT - YOAV
  58. CURRENT – YOAV NEXT - YOAV
  59. CURRENT – YOAV NEXT - YOAV
  60. CURRENT – YOAV NEXT - YOAV
  61. CURRENT – YOAV NEXT - JB
  62. CURRENT – YOAV NEXT - JB
  63. CURRENT – YOAV NEXT - JB
  64. CURRENT – YOAV NEXT - JB
  65. CURRENT – YOAV NEXT - JB
  66. CURRENT – YOAV NEXT - JB
  67. CURRENT – YOAV NEXT - JB
  68. CURRENT – YOAV NEXT - JB
  69. CURRENT – YOAV NEXT - JB
  70. CURRENT – YOAV NEXT - JB
  71. CURRENT – JB NEXT - JB
  72. CURRENT – JB NEXT - JB
  73. CURRENT – JB NEXT - JB
  74. CURRENT – JB NEXT - JB
  75. CURRENT – JB NEXT - JB
  76. CURRENT – JB NEXT - JB
  77. CURRENT – JB NEXT - JB
  78. CURRENT – JB NEXT - YOAV
  79. CURRENT – JB NEXT - YOAV
  80. CURRENT – JB NEXT - YOAV
  81. CURRENT – JB NEXT - YOAV
  82. CURRENT – JB NEXT - YOAV
  83. CURRENT – JB NEXT - YOAV
  84. CURRENT – YOAV NEXT - YOAV
  85. CURRENT – YOAV NEXT - YOAV
  86. CURRENT – YOAV NEXT - YOAV
  87. CURRENT – YOAV NEXT - YOAV
  88. CURRENT – YOAV NEXT - YOAV
  89. CURRENT – YOAV NEXT - YOAV
  90. CURRENT – YOAV NEXT - YOAV
  91. CURRENT – YOAV NEXT - YOAV
  92. CURRENT – YOAV NEXT - YOAV
  93. CURRENT – YOAV NEXT - JB 1993
  94. CURRENT – YOAV NEXT - JB
  95. CURRENT – YOAV NEXT - JB
  96. CURRENT – YOAV NEXT - JB
  97. CURRENT – YOAV NEXT - JB
  98. CURRENT – YOAV NEXT - JB
  99. CURRENT – YOAV NEXT - JB
  100. CURRENT – JB NEXT - JB
  101. CURRENT – JB NEXT - JB
  102. CURRENT – JB NEXT - JB
  103. CURRENT – JB NEXT - JB
  104. CURRENT – JB NEXT - JB
  105. CURRENT – JB NEXT - JB
  106. CURRENT – JB NEXT - JB
  107. CURRENT – JB NEXT - JB
  108. CURRENT – JB NEXT - JB
  109. CURRENT – JB NEXT - JB
  110. CURRENT – JB NEXT - JB
  111. CURRENT – JB NEXT - JB
  112. CURRENT – JB NEXT - JB
  113. CURRENT – JB NEXT - YOAV (1983)
  114. CURRENT – JB NEXT - YOAV
  115. CURRENT – JB NEXT - YOAV
  116. CURRENT – JB NEXT - YOAV
  117. CURRENT – JB NEXT - YOAV
  118. CURRENT – JB NEXT - YOAV
  119. CURRENT – JB NEXT - YOAV
  120. CURRENT – JB NEXT - YOAV
  121. CURRENT – JB NEXT - YOAV
  122. CURRENT – YOAV NEXT - JB
  123. CURRENT – YOAV NEXT - JB
  124. CURRENT – YOAV NEXT - JB
  125. CURRENT – YOAV NEXT - JB
  126. CURRENT – YOAV NEXT - JB
  127. CURRENT – YOAV NEXT - JB
  128. CURRENT – YOAV NEXT - JB
  129. CURRENT – YOAV NEXT - JB
  130. CURRENT – YOAV NEXT - JB
  131. CURRENT – JB
  132. CURRENT – JB
  133. CURRENT – JB
  134. CURRENT – JB
  135. CURRENT – JB
  136. CURRENT – JB
  137. CURRENT – JB
  138. CURRENT – JB
  139. CURRENT – JB
  140. CURRENT – FRED