a brief introduction to 11acm 朱旻申. outline what is groovy ? differences between groovy &...
TRANSCRIPT
![Page 1: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/1.jpg)
A brief introduction to
11ACM朱旻申
Groovy
![Page 2: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/2.jpg)
Outline
What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods
![Page 3: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/3.jpg)
Groovy …
An agile and dynamic language for the Java Virtual Machine
Builds upon the strengths of Java but has additional power features inspired by languages like Python, Ruby and Smalltalk
Provides the ability to statically type check and statically compile your code
![Page 4: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/4.jpg)
An Example
In Groovy :
In Java :
![Page 5: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/5.jpg)
Grammar vs Java
No “;”, “()” & “public” No constructor, no “return” No types, everything is an object Closure
![Page 6: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/6.jpg)
Grammar
Java without types
![Page 7: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/7.jpg)
Grammar
Loop
![Page 8: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/8.jpg)
Grammar
Use “?” to avoid NULL pointer call
![Page 9: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/9.jpg)
Closure
Codes in “{}”
![Page 10: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/10.jpg)
Closure in iteration
![Page 11: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/11.jpg)
Closure in iteration
![Page 12: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/12.jpg)
Dagger Methods
Short, small but efficient Mostly implemented by closure
![Page 13: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/13.jpg)
eachWithIndex
Running results :1 : a2 : b3 : c
![Page 14: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/14.jpg)
any & every
Running results :truefalse
![Page 15: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/15.jpg)
grep
[‘a’, ‘ab’]
[‘ab’]
![Page 16: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/16.jpg)
sort
Running results :7, 23, 2012
![Page 17: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/17.jpg)
References
http:\\groovy.codehaus.org Wikipedia百度文库
![Page 18: A brief introduction to 11ACM 朱旻申. Outline What is Groovy ? Differences between Groovy & Java About closure & Dagger Methods](https://reader036.vdocuments.net/reader036/viewer/2022062802/56649e9c5503460f94b9d377/html5/thumbnails/18.jpg)
Thanks for listening !