SlideShare a Scribd company logo
1 of 165
1. Два клЕвых пацана на сцене 
2. Прикольные загадки 
3. Вы голосуете за правильный 
ответ 
4. Мы швыряемся вещами 
5. Официальный хэш! 
groovypuzzlers
-3.abs()
int value = -3 
value.abs() 
(-3).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)
“Все проблемы в программировании 
можно решить добавив пару скобок” 
John McCarthy, изобретатель LISP
println ((-3).abs()) 
int value = -3 
println value.abs()
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/responses-to-the-closure-of-no-return/
class Conference {def name; def year} 
def gr = new Conference(name: 'Greach', year: 2014) 
gr.each {println it}
List<Integer> list = [56, '9', 74] 
def max = list.max { item -> 
(item < 50) ? item : null 
} 
println max
List<Integer> list = [56, '9', 74] 
def max = list.max { item -> 
(item < 50) ? item : null 
} 
println max
>groovysh (('9' as Character) as Integer) 
===> 57
List<Integer> list = [56, 57, 74] 
def max = list.max { item -> 
(item < 50) ? item : null 
} 
println max
List<Integer> list = [56, '9', 74] 
def max = list.max { item -> 
(item < 50) ? item : null 
} 
println max
def random = new Random() 
def randomList = [] 
0..10.each {randomList << random.nextInt()} 
assert randomList.max{ null } == randomList[0]
Closure ктоУбийца() { 
{ 
'Мориарти.' 
} 
} 
println ктоУбийца()
Closure ктоУбийца() { 
Closure ктоУбийца() { 
{ -> 
'Мориарти.' 
} 
} 
return { 
'Мориарти.' 
} 
}
class CountDown { int counter = 10 } 
CountDown finalCountDown() { 
def countDown = new CountDown() 
try { 
countDown.counter = --countDown.counter 
} catch (ignored) { 
println "That will never happen." 
countDown.counter = Integer.MIN_VALUE 
} finally { 
return countDown 
} 
} 
println finalCountDown().counter
class CountDown { int counter = 10 } 
CountDown finalCountDown() { 
def countDown = new CountDown() 
try { 
countDown.counter = --countDown.counter 
} catch (ignored) { 
println "That will never happen." 
countDown.counter = Integer.MIN_VALUE 
} finally { 
return countDown 
} 
} 
println finalCountDown().counter
class CountDown { int counter = 10 } 
CountDown finalCountDown() { 
def countDown = new CountDown() 
try { 
countDown.counter = --countDown.counter 
} catch (ignored) { 
ignored.printStackTrace() 
countDown.counter = Integer.MIN_VALUE 
} finally { 
return countDown 
} 
} 
println finalCountDown().counter 
org.codehaus.groovy.runtime.typehandling.GroovyCastException: 
Cannot cast object '9' with class 'java.lang.Integer' to class 'CountDown’ 
-2147483648
class CountDown { int counter = 10 } 
CountDown finalCountDown() { 
def countDown = new CountDown() 
try { 
countDown.counter = --countDown.counter 
} catch (ignored) { 
println "That will never happen." 
countDown.counter = Integer.MIN_VALUE 
} finally { 
return countDown 
} 
42 
} 
println finalCountDown().counter
class CountDown { int counter = 10 } 
CountDown finalCountDown() { 
def countDown = new CountDown() 
try { 
countDown.counter = --countDown.counter 
} catch (ignored) { 
println "That will never happen." 
countDown.counter = Integer.MIN_VALUE 
} finally { 
return countDown 
} 
42 
} 
println finalCountDown().counter
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-traits.html
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." " = '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
def key = 'x' 
def map = ["${key}": 'treasure'] 
def value = map['x'] 
println value
def key = 'x' 
def map = ["${key}": 'treasure'] 
def value = map['x'] 
println value
def map = ["${key}": 'treasure'] 
println map.keySet().first().class.name 
org.codehaus.groovy.runtime.GStringImpl
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) }
[0..9].each { println(it - 1) } 
Это неправильные 
скобки!
(0..9).each { println(it - 1) } 
Другое дело!
[0, 2, 3, 4, 5, 6, 7, 8, 9]
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]
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() 
def attendees = invite.attending +1 
Как убрать скобки?!
class MrHyde { 
def me() { 
return this 
} 
} 
class DrJekyll { 
} 
DrJekyll.mixin MrHyde 
def drJekyll = new DrJekyll().me() as DrJekyll 
def mrHide = new DrJekyll().me() 
println "$drJekyll and $mrHide, are they the 
same? ${(drJekyll.class).equals(mrHide.class)}"
class MrHyde { 
def me() { 
return this 
} 
} 
class DrJekyll { 
} 
DrJekyll.mixin MrHyde 
def drJekyll = new DrJekyll().me() as DrJekyll 
def mrHide = new DrJekyll().me() 
println "$drJekyll and $mrHide, are they the same? 
${(drJekyll.class).equals(mrHide.class)}"
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 
}
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()
def map = [metaClass: ‘frequency'] 
println "What's the $map.metaClass, Барух?"
map.metaClass 
map.get('metaClass') 
map.getMetaClass()
1. Пишите читабельный код 
2. Комментируйте все трюки 
3. Иногда это баг 
4. Пользуйте static code analysis - intellij 
IDEA! 
5. Rtfm 
6. Don’t code like my brother
Мы только начали! (надо еще 
форму придумать) 
Засылайте Ваши паззлеры, поделки 
и рисунки 
- puzzlers jfrog.com 
- Groovypuzzlers
Вам понравилось? 
Хвалите нас в твиттере 
groovypuzzlers 
- Groovypuzzlers 
- jekaborisov 
- jbaruch 
Вам не поравилось? 
/dev/null
Groovy puzzlers по русски с Joker 2014

More Related Content

What's hot

Are we ready to Go?
Are we ready to Go?Are we ready to Go?
Are we ready to Go?Adam Dudczak
 
Fertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureFertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureMike Fogus
 
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークGroovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークTsuyoshi Yamamoto
 
The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)GroovyPuzzlers
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. ExperienceMike Fogus
 
Python легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачиPython легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачиMaxim Kulsha
 
The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184Mahmoud Samir Fayed
 
The Macronomicon
The MacronomiconThe Macronomicon
The MacronomiconMike Fogus
 
RxSwift 시작하기
RxSwift 시작하기RxSwift 시작하기
RxSwift 시작하기Suyeol Jeon
 
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFrom java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
 
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFrom Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFabio Collini
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語ikdysfm
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기JangHyuk You
 
Functional Patterns for the non-mathematician
Functional Patterns for the non-mathematicianFunctional Patterns for the non-mathematician
Functional Patterns for the non-mathematicianBrian Lonsdorf
 
Kotlin from-scratch 2 - functions
Kotlin from-scratch 2 - functionsKotlin from-scratch 2 - functions
Kotlin from-scratch 2 - functionsFranco Lombardo
 
Numerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingNumerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingUtsav Patel
 
How to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftHow to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftGiordano Scalzo
 

What's hot (20)

Are we ready to Go?
Are we ready to Go?Are we ready to Go?
Are we ready to Go?
 
Fertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureFertile Ground: The Roots of Clojure
Fertile Ground: The Roots of Clojure
 
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークGroovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトーク
 
The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. Experience
 
Python легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачиPython легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачи
 
The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184
 
The Macronomicon
The MacronomiconThe Macronomicon
The Macronomicon
 
Millionways
MillionwaysMillionways
Millionways
 
RxSwift 시작하기
RxSwift 시작하기RxSwift 시작하기
RxSwift 시작하기
 
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFrom java to kotlin beyond alt+shift+cmd+k - Droidcon italy
From java to kotlin beyond alt+shift+cmd+k - Droidcon italy
 
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFrom Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기
 
Functional Patterns for the non-mathematician
Functional Patterns for the non-mathematicianFunctional Patterns for the non-mathematician
Functional Patterns for the non-mathematician
 
Kotlin from-scratch 2 - functions
Kotlin from-scratch 2 - functionsKotlin from-scratch 2 - functions
Kotlin from-scratch 2 - functions
 
Introduzione a C#
Introduzione a C#Introduzione a C#
Introduzione a C#
 
Numerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingNumerical Methods with Computer Programming
Numerical Methods with Computer Programming
 
How to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftHow to Clone Flappy Bird in Swift
How to Clone Flappy Bird in Swift
 
ES6 in Real Life
ES6 in Real LifeES6 in Real Life
ES6 in Real Life
 

Similar to Groovy puzzlers по русски с Joker 2014

The groovy puzzlers (as Presented at Gr8Conf US 2014)
The groovy puzzlers (as Presented at Gr8Conf US 2014)The groovy puzzlers (as Presented at Gr8Conf US 2014)
The groovy puzzlers (as Presented at Gr8Conf US 2014)GroovyPuzzlers
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with GroovyArturo Herrero
 
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
 
Monadologie
MonadologieMonadologie
Monadologieleague
 
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
 
A swift introduction to Swift
A swift introduction to SwiftA swift introduction to Swift
A swift introduction to SwiftGiordano Scalzo
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScriptniklal
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecLoïc Descotte
 
여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala LanguageAshal aka JOKER
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming iiPrashant Kalkar
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingMuthu Vinayagam
 

Similar to Groovy puzzlers по русски с Joker 2014 (20)

The groovy puzzlers (as Presented at Gr8Conf US 2014)
The groovy puzzlers (as Presented at Gr8Conf US 2014)The groovy puzzlers (as Presented at Gr8Conf US 2014)
The groovy puzzlers (as Presented at Gr8Conf US 2014)
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with Groovy
 
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
 
Monadologie
MonadologieMonadologie
Monadologie
 
Kotlin
KotlinKotlin
Kotlin
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
 
Clojure入門
Clojure入門Clojure入門
Clojure入門
 
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
 
Pooya Khaloo Presentation on IWMC 2015
Pooya Khaloo Presentation on IWMC 2015Pooya Khaloo Presentation on IWMC 2015
Pooya Khaloo Presentation on IWMC 2015
 
A swift introduction to Swift
A swift introduction to SwiftA swift introduction to Swift
A swift introduction to Swift
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScript
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
 
ddd+scala
ddd+scaladdd+scala
ddd+scala
 
Benefits of Kotlin
Benefits of KotlinBenefits of Kotlin
Benefits of Kotlin
 
여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language
 
Java VS Python
Java VS PythonJava VS Python
Java VS Python
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
 

More from Baruch Sadogursky

DevOps Patterns & Antipatterns for Continuous Software Updates @ NADOG April ...
DevOps Patterns & Antipatterns for Continuous Software Updates @ NADOG April ...DevOps Patterns & Antipatterns for Continuous Software Updates @ NADOG April ...
DevOps Patterns & Antipatterns for Continuous Software Updates @ NADOG April ...Baruch Sadogursky
 
DevOps Patterns & Antipatterns for Continuous Software Updates @ DevOps.com A...
DevOps Patterns & Antipatterns for Continuous Software Updates @ DevOps.com A...DevOps Patterns & Antipatterns for Continuous Software Updates @ DevOps.com A...
DevOps Patterns & Antipatterns for Continuous Software Updates @ DevOps.com A...Baruch Sadogursky
 
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Oracle Code NY...
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Oracle Code NY...DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Oracle Code NY...
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Oracle Code NY...Baruch Sadogursky
 
Data driven devops as presented at QCon London 2018
Data driven devops as presented at QCon London 2018Data driven devops as presented at QCon London 2018
Data driven devops as presented at QCon London 2018Baruch Sadogursky
 
A Research Study Into DevOps Bottlenecks as presented at Oracle Code LA 2018
A Research Study Into DevOps Bottlenecks as presented at Oracle Code LA 2018A Research Study Into DevOps Bottlenecks as presented at Oracle Code LA 2018
A Research Study Into DevOps Bottlenecks as presented at Oracle Code LA 2018Baruch Sadogursky
 
Java Puzzlers NG S03 a DevNexus 2018
Java Puzzlers NG S03 a DevNexus 2018Java Puzzlers NG S03 a DevNexus 2018
Java Puzzlers NG S03 a DevNexus 2018Baruch Sadogursky
 
Where the Helm are your binaries? as presented at Canada Kubernetes Meetups
Where the Helm are your binaries? as presented at Canada Kubernetes MeetupsWhere the Helm are your binaries? as presented at Canada Kubernetes Meetups
Where the Helm are your binaries? as presented at Canada Kubernetes MeetupsBaruch Sadogursky
 
Data driven devops as presented at Codemash 2018
Data driven devops as presented at Codemash 2018Data driven devops as presented at Codemash 2018
Data driven devops as presented at Codemash 2018Baruch Sadogursky
 
A Research Study into DevOps Bottlenecks as presented at Codemash 2018
A Research Study into DevOps Bottlenecks as presented at Codemash 2018A Research Study into DevOps Bottlenecks as presented at Codemash 2018
A Research Study into DevOps Bottlenecks as presented at Codemash 2018Baruch Sadogursky
 
Best Practices for Managing Docker Versions as presented at JavaOne 2017
Best Practices for Managing Docker Versions as presented at JavaOne 2017Best Practices for Managing Docker Versions as presented at JavaOne 2017
Best Practices for Managing Docker Versions as presented at JavaOne 2017Baruch Sadogursky
 
Troubleshooting & Debugging Production Microservices in Kubernetes as present...
Troubleshooting & Debugging Production Microservices in Kubernetes as present...Troubleshooting & Debugging Production Microservices in Kubernetes as present...
Troubleshooting & Debugging Production Microservices in Kubernetes as present...Baruch Sadogursky
 
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Devoxx 2017
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Devoxx 2017DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Devoxx 2017
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Devoxx 2017Baruch Sadogursky
 
Amazon Alexa Skills vs Google Home Actions, the Big Java VUI Faceoff as prese...
Amazon Alexa Skills vs Google Home Actions, the Big Java VUI Faceoff as prese...Amazon Alexa Skills vs Google Home Actions, the Big Java VUI Faceoff as prese...
Amazon Alexa Skills vs Google Home Actions, the Big Java VUI Faceoff as prese...Baruch Sadogursky
 
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at DevOps Days Be...
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at DevOps Days Be...DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at DevOps Days Be...
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at DevOps Days Be...Baruch Sadogursky
 
Java Puzzlers NG S02: Down the Rabbit Hole as it was presented at The Pittsbu...
Java Puzzlers NG S02: Down the Rabbit Hole as it was presented at The Pittsbu...Java Puzzlers NG S02: Down the Rabbit Hole as it was presented at The Pittsbu...
Java Puzzlers NG S02: Down the Rabbit Hole as it was presented at The Pittsbu...Baruch Sadogursky
 
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at The Pittsburgh...
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at The Pittsburgh...DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at The Pittsburgh...
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at The Pittsburgh...Baruch Sadogursky
 
Let’s Wing It: A Study in DevRel Strategy
 Let’s Wing It: A Study in DevRel Strategy Let’s Wing It: A Study in DevRel Strategy
Let’s Wing It: A Study in DevRel StrategyBaruch Sadogursky
 
Log Driven First Class Customer Support at Scale
Log Driven First Class Customer Support at ScaleLog Driven First Class Customer Support at Scale
Log Driven First Class Customer Support at ScaleBaruch Sadogursky
 
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOpsBaruch Sadogursky
 
Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...
Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...
Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...Baruch Sadogursky
 

More from Baruch Sadogursky (20)

DevOps Patterns & Antipatterns for Continuous Software Updates @ NADOG April ...
DevOps Patterns & Antipatterns for Continuous Software Updates @ NADOG April ...DevOps Patterns & Antipatterns for Continuous Software Updates @ NADOG April ...
DevOps Patterns & Antipatterns for Continuous Software Updates @ NADOG April ...
 
DevOps Patterns & Antipatterns for Continuous Software Updates @ DevOps.com A...
DevOps Patterns & Antipatterns for Continuous Software Updates @ DevOps.com A...DevOps Patterns & Antipatterns for Continuous Software Updates @ DevOps.com A...
DevOps Patterns & Antipatterns for Continuous Software Updates @ DevOps.com A...
 
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Oracle Code NY...
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Oracle Code NY...DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Oracle Code NY...
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Oracle Code NY...
 
Data driven devops as presented at QCon London 2018
Data driven devops as presented at QCon London 2018Data driven devops as presented at QCon London 2018
Data driven devops as presented at QCon London 2018
 
A Research Study Into DevOps Bottlenecks as presented at Oracle Code LA 2018
A Research Study Into DevOps Bottlenecks as presented at Oracle Code LA 2018A Research Study Into DevOps Bottlenecks as presented at Oracle Code LA 2018
A Research Study Into DevOps Bottlenecks as presented at Oracle Code LA 2018
 
Java Puzzlers NG S03 a DevNexus 2018
Java Puzzlers NG S03 a DevNexus 2018Java Puzzlers NG S03 a DevNexus 2018
Java Puzzlers NG S03 a DevNexus 2018
 
Where the Helm are your binaries? as presented at Canada Kubernetes Meetups
Where the Helm are your binaries? as presented at Canada Kubernetes MeetupsWhere the Helm are your binaries? as presented at Canada Kubernetes Meetups
Where the Helm are your binaries? as presented at Canada Kubernetes Meetups
 
Data driven devops as presented at Codemash 2018
Data driven devops as presented at Codemash 2018Data driven devops as presented at Codemash 2018
Data driven devops as presented at Codemash 2018
 
A Research Study into DevOps Bottlenecks as presented at Codemash 2018
A Research Study into DevOps Bottlenecks as presented at Codemash 2018A Research Study into DevOps Bottlenecks as presented at Codemash 2018
A Research Study into DevOps Bottlenecks as presented at Codemash 2018
 
Best Practices for Managing Docker Versions as presented at JavaOne 2017
Best Practices for Managing Docker Versions as presented at JavaOne 2017Best Practices for Managing Docker Versions as presented at JavaOne 2017
Best Practices for Managing Docker Versions as presented at JavaOne 2017
 
Troubleshooting & Debugging Production Microservices in Kubernetes as present...
Troubleshooting & Debugging Production Microservices in Kubernetes as present...Troubleshooting & Debugging Production Microservices in Kubernetes as present...
Troubleshooting & Debugging Production Microservices in Kubernetes as present...
 
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Devoxx 2017
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Devoxx 2017DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Devoxx 2017
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at Devoxx 2017
 
Amazon Alexa Skills vs Google Home Actions, the Big Java VUI Faceoff as prese...
Amazon Alexa Skills vs Google Home Actions, the Big Java VUI Faceoff as prese...Amazon Alexa Skills vs Google Home Actions, the Big Java VUI Faceoff as prese...
Amazon Alexa Skills vs Google Home Actions, the Big Java VUI Faceoff as prese...
 
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at DevOps Days Be...
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at DevOps Days Be...DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at DevOps Days Be...
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at DevOps Days Be...
 
Java Puzzlers NG S02: Down the Rabbit Hole as it was presented at The Pittsbu...
Java Puzzlers NG S02: Down the Rabbit Hole as it was presented at The Pittsbu...Java Puzzlers NG S02: Down the Rabbit Hole as it was presented at The Pittsbu...
Java Puzzlers NG S02: Down the Rabbit Hole as it was presented at The Pittsbu...
 
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at The Pittsburgh...
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at The Pittsburgh...DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at The Pittsburgh...
DevOps @Scale (Greek Tragedy in 3 Acts) as it was presented at The Pittsburgh...
 
Let’s Wing It: A Study in DevRel Strategy
 Let’s Wing It: A Study in DevRel Strategy Let’s Wing It: A Study in DevRel Strategy
Let’s Wing It: A Study in DevRel Strategy
 
Log Driven First Class Customer Support at Scale
Log Driven First Class Customer Support at ScaleLog Driven First Class Customer Support at Scale
Log Driven First Class Customer Support at Scale
 
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps
 
Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...
Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...
Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...
 

Recently uploaded

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Recently uploaded (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
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
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

Groovy puzzlers по русски с Joker 2014

  • 1.
  • 2.
  • 3. 1. Два клЕвых пацана на сцене 2. Прикольные загадки 3. Вы голосуете за правильный ответ 4. Мы швыряемся вещами 5. Официальный хэш! groovypuzzlers
  • 4.
  • 5.
  • 6.
  • 7.
  • 9.
  • 10. int value = -3 value.abs() (-3).abs()
  • 11.
  • 13.
  • 14.
  • 15. 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)
  • 16. “Все проблемы в программировании можно решить добавив пару скобок” John McCarthy, изобретатель LISP
  • 17. println ((-3).abs()) int value = -3 println value.abs()
  • 18.
  • 19. 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)
  • 20.
  • 21. 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)
  • 22. 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)
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 30.
  • 31. class Conference {def name; def year} def gr = new Conference(name: 'Greach', year: 2014) gr.each {println it}
  • 32.
  • 33.
  • 34.
  • 35. List<Integer> list = [56, '9', 74] def max = list.max { item -> (item < 50) ? item : null } println max
  • 36. List<Integer> list = [56, '9', 74] def max = list.max { item -> (item < 50) ? item : null } println max
  • 37. >groovysh (('9' as Character) as Integer) ===> 57
  • 38. List<Integer> list = [56, 57, 74] def max = list.max { item -> (item < 50) ? item : null } println max
  • 39.
  • 40. List<Integer> list = [56, '9', 74] def max = list.max { item -> (item < 50) ? item : null } println max
  • 41.
  • 42. def random = new Random() def randomList = [] 0..10.each {randomList << random.nextInt()} assert randomList.max{ null } == randomList[0]
  • 43.
  • 44.
  • 45. Closure ктоУбийца() { { 'Мориарти.' } } println ктоУбийца()
  • 46.
  • 47. Closure ктоУбийца() { Closure ктоУбийца() { { -> 'Мориарти.' } } return { 'Мориарти.' } }
  • 48.
  • 49. class CountDown { int counter = 10 } CountDown finalCountDown() { def countDown = new CountDown() try { countDown.counter = --countDown.counter } catch (ignored) { println "That will never happen." countDown.counter = Integer.MIN_VALUE } finally { return countDown } } println finalCountDown().counter
  • 50. class CountDown { int counter = 10 } CountDown finalCountDown() { def countDown = new CountDown() try { countDown.counter = --countDown.counter } catch (ignored) { println "That will never happen." countDown.counter = Integer.MIN_VALUE } finally { return countDown } } println finalCountDown().counter
  • 51.
  • 52. class CountDown { int counter = 10 } CountDown finalCountDown() { def countDown = new CountDown() try { countDown.counter = --countDown.counter } catch (ignored) { ignored.printStackTrace() countDown.counter = Integer.MIN_VALUE } finally { return countDown } } println finalCountDown().counter org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '9' with class 'java.lang.Integer' to class 'CountDown’ -2147483648
  • 53.
  • 54.
  • 55. class CountDown { int counter = 10 } CountDown finalCountDown() { def countDown = new CountDown() try { countDown.counter = --countDown.counter } catch (ignored) { println "That will never happen." countDown.counter = Integer.MIN_VALUE } finally { return countDown } 42 } println finalCountDown().counter
  • 56. class CountDown { int counter = 10 } CountDown finalCountDown() { def countDown = new CountDown() try { countDown.counter = --countDown.counter } catch (ignored) { println "That will never happen." countDown.counter = Integer.MIN_VALUE } finally { return countDown } 42 } println finalCountDown().counter
  • 57.
  • 58.
  • 59.
  • 61. trait Public { public String property = "I am all public!" } class Property implements Public {} Property publicProperty = new Property()
  • 62. trait Public { public String property = "I am all public!" } class Property implements Public {} Property publicProperty = new Property()
  • 63.
  • 64.
  • 65. А ты документацию читать не пробовал??? http://beta.groovy-lang.org/docs/groovy-2.3.0/html/documentation/core-traits.html
  • 66.
  • 67. def key = 'x' def map = [key: 'treasure'] def value = map.get(key) println value
  • 68. def key = 'x' def map = [key: 'treasure'] def value = map.get(key) println value
  • 69.
  • 70.
  • 71. 1.def map = [(key): 'treasure'] 2.map.put(key, 'treasure') 3.map[key] = 'treasure' 4.map." " = 'treasure'
  • 72.
  • 73. def map = [2: 'treasure'] def key = 2 def value = map."$key" println value
  • 74. def map = [2: 'treasure'] def key = 2 def value = map."$key" println value
  • 75.
  • 76. def map = [2: 'treasure'] println map.keySet().first().class.name java.lang.Integer
  • 77.
  • 78. def key = 'x' def map = ["${key}": 'treasure'] def value = map['x'] println value
  • 79. def key = 'x' def map = ["${key}": 'treasure'] def value = map['x'] println value
  • 80.
  • 81. def map = ["${key}": 'treasure'] println map.keySet().first().class.name org.codehaus.groovy.runtime.GStringImpl
  • 82.
  • 83. def range = 1.0..10.0 assert range.contains(5.0) println range.contains(5.6)
  • 84.
  • 85.
  • 86.
  • 87.
  • 88. 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
  • 89.
  • 90.
  • 91.
  • 92.
  • 94.
  • 95. [0..9].each { println(it - 1) } Это неправильные скобки!
  • 96. (0..9).each { println(it - 1) } Другое дело!
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102. [0, 2, 3, 4, 5, 6, 7, 8, 9]
  • 103.
  • 104.
  • 105. List<Long> list = [1,2,3] def now = new Date() list << now println list
  • 106. List<Long> list = [1,2,3] def now = new Date() list << now println list
  • 107.
  • 108.
  • 109.
  • 110.
  • 111. 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]
  • 112.
  • 113.
  • 114. double value = 3 println "$value.14".isDouble()
  • 115.
  • 116.
  • 117.
  • 118. double value = 3 println "$value.14".isDouble()
  • 119.
  • 120.
  • 121.
  • 122.
  • 123. class Invite { int attending = 1 } def invite = new Invite() def attendees = (invite.attending) +1 println attendees
  • 124. class Invite { int attending = 1 } def invite = new Invite() def attendees = (invite.attending) +1 println attendees
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130. def attendees = (new Invite().attending) + 1 println attendees
  • 131. def invite = new Invite() def attendees = invite.attending +1 Как убрать скобки?!
  • 132.
  • 133. class MrHyde { def me() { return this } } class DrJekyll { } DrJekyll.mixin MrHyde def drJekyll = new DrJekyll().me() as DrJekyll def mrHide = new DrJekyll().me() println "$drJekyll and $mrHide, are they the same? ${(drJekyll.class).equals(mrHide.class)}"
  • 134. class MrHyde { def me() { return this } } class DrJekyll { } DrJekyll.mixin MrHyde def drJekyll = new DrJekyll().me() as DrJekyll def mrHide = new DrJekyll().me() println "$drJekyll and $mrHide, are they the same? ${(drJekyll.class).equals(mrHide.class)}"
  • 135.
  • 136.
  • 137.
  • 138.
  • 139.
  • 140. def x = int println x if ((x = long)) { println x } if (x = boolean ) { println x }
  • 141. def x = int println x if ((x = long)) { println x } if (x = boolean ) { println x }
  • 142.
  • 143.
  • 144.
  • 145.
  • 146. class VanHalen { public static jump() { "Here are the ${lyrics()}" } def methodMissing(String name, def args) { 'lyrics' } } println VanHalen.jump()
  • 147. class VanHalen { public static jump() { "Here are the ${lyrics()}" } def methodMissing(String name, def args) { 'lyrics' } } println VanHalen.jump()
  • 148.
  • 149.
  • 150.
  • 151.
  • 152. class VanHalen { public static jump() { "Here are the ${lyrics()}" } static $static_methodMissing(String name, def args) { 'lyrics' } } println VanHalen.jump()
  • 153. class VanHalen { public jump() { "Here are the ${lyrics()}" } def methodMissing(String name, def args) { 'lyrics' } } println new VanHalen().jump()
  • 154.
  • 155. def map = [metaClass: ‘frequency'] println "What's the $map.metaClass, Барух?"
  • 156.
  • 157.
  • 159.
  • 160.
  • 161. 1. Пишите читабельный код 2. Комментируйте все трюки 3. Иногда это баг 4. Пользуйте static code analysis - intellij IDEA! 5. Rtfm 6. Don’t code like my brother
  • 162. Мы только начали! (надо еще форму придумать) Засылайте Ваши паззлеры, поделки и рисунки - puzzlers jfrog.com - Groovypuzzlers
  • 163.
  • 164. Вам понравилось? Хвалите нас в твиттере groovypuzzlers - Groovypuzzlers - jekaborisov - jbaruch Вам не поравилось? /dev/null

Editor's Notes

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