Groovy: Fly Beyond Java Copyright © 2001-2008 Infor Global Solutions
Agenda <ul><li>Why Groovy Appears </li></ul><ul><li>How Groovy Rocks </li></ul>
<ul><li>什 么是 好 的程序语言? </li></ul>
CEO 的梦想 =
程序员的梦想 写程序 泡网 午饭 和美眉网聊 打游戏 下班
Copyright © 2001-2006 Infor Global Solutions 哪种编程语言更“好”? 义 義 好 的编程语言也许应该更像是一门 “ 语言 ”
Copyright © 2001-2006 Infor Global Solutions 于是 Groovy 诞生了 Groovy 使得 Java 更“ 语言 ” Java 的 强大技术 类 Ruby 等动态语言 的轻盈语法 Groovy
Copyright © 2001-2006 Infor Global Solutions 欢迎来到简洁美妙的 Groovy 世界
Copyright © 2001-2006 Infor Global Solutions 别在乎类型 Java: String name = “abc”; Groovy: String name = “abc” def  name name =...
Copyright © 2001-2006 Infor Global Solutions “ 直接”访问属性 class Person { private String name; public Person(String name) {thi...
Copyright © 2001-2006 Infor Global Solutions 了不起的字符串 firstName = “ocean” lastName = “dong” message = “My name is  $ firstN...
Copyright © 2001-2006 Infor Global Solutions 集合:简单类型而已 List: def aList = [1, 2, 3] def aList = [10, “abc”, new Date()] Map...
Copyright © 2001-2006 Infor Global Solutions 可爱的操作符 [1, 2, 3]  <<  4 def aMap = [a:1, b:2] println aMap . a println aMap [...
Copyright © 2001-2006 Infor Global Solutions 万物皆可判断 If(1) assert 1 def aList = [1, 2, 3] If(aList) assert aList def person...
Copyright © 2001-2006 Infor Global Solutions 四通八达的 Switch switch(10) { case 0: case 0..9: case [8,9,11]: case Float: case ...
Copyright © 2001-2006 Infor Global Solutions 透明的集合 ArrayList names = new ArrayList() for(Person person : persons) { names....
Copyright © 2001-2006 Infor Global Solutions Closure:  终极代码重用 ArrayList persons = … for(Person person : persons) { System....
Copyright © 2001-2006 Infor Global Solutions 远远不止这些哦。。。 Builder Meta Programming Groovylet GSP GRails Scriptom Griffon GMa...
Thanks
Upcoming SlideShare
Loading in …5
×

Groovy Intro

745 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
745
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Introduce wiki page
  • Introduce wiki page
  • Introduce wiki page
  • Introduce wiki page
  • Groovy Intro

    1. 1. Groovy: Fly Beyond Java Copyright © 2001-2008 Infor Global Solutions
    2. 2. Agenda <ul><li>Why Groovy Appears </li></ul><ul><li>How Groovy Rocks </li></ul>
    3. 3. <ul><li>什 么是 好 的程序语言? </li></ul>
    4. 4. CEO 的梦想 =
    5. 5. 程序员的梦想 写程序 泡网 午饭 和美眉网聊 打游戏 下班
    6. 6. Copyright © 2001-2006 Infor Global Solutions 哪种编程语言更“好”? 义 義 好 的编程语言也许应该更像是一门 “ 语言 ”
    7. 7. Copyright © 2001-2006 Infor Global Solutions 于是 Groovy 诞生了 Groovy 使得 Java 更“ 语言 ” Java 的 强大技术 类 Ruby 等动态语言 的轻盈语法 Groovy
    8. 8. Copyright © 2001-2006 Infor Global Solutions 欢迎来到简洁美妙的 Groovy 世界
    9. 9. Copyright © 2001-2006 Infor Global Solutions 别在乎类型 Java: String name = “abc”; Groovy: String name = “abc” def name name = “abc”
    10. 10. Copyright © 2001-2006 Infor Global Solutions “ 直接”访问属性 class Person { private String name; public Person(String name) {this.name = name;} public String getName() {return name;} } Person person = new person(“ocean”) return person.getName(); class Person { String name; } Person person = new Person(name:”ocean”) return person .name
    11. 11. Copyright © 2001-2006 Infor Global Solutions 了不起的字符串 firstName = “ocean” lastName = “dong” message = “My name is $ firstName $ lastName” person = new Person() person.setName(“ocean”) message = “My name is ${ person.name } ” Message = “ ““ Hi, My name is ${person.name} ””” def pattern = / hello.* /
    12. 12. Copyright © 2001-2006 Infor Global Solutions 集合:简单类型而已 List: def aList = [1, 2, 3] def aList = [10, “abc”, new Date()] Map: def aMap = [a:1, b:2] Range: def aRange = ‘a’..’z’ def numbers = 0..<10
    13. 13. Copyright © 2001-2006 Infor Global Solutions 可爱的操作符 [1, 2, 3] << 4 def aMap = [a:1, b:2] println aMap . a println aMap [ a ] “ hello world” =~ /hello.*/ println person ? .wife ? .name
    14. 14. Copyright © 2001-2006 Infor Global Solutions 万物皆可判断 If(1) assert 1 def aList = [1, 2, 3] If(aList) assert aList def person If(person) assert !person
    15. 15. Copyright © 2001-2006 Infor Global Solutions 四通八达的 Switch switch(10) { case 0: case 0..9: case [8,9,11]: case Float: case {it % 3 == 0}: case ~/../: default: }
    16. 16. Copyright © 2001-2006 Infor Global Solutions 透明的集合 ArrayList names = new ArrayList() for(Person person : persons) { names.add(person.getName()); } return names; def persons = [new Person(”ocean”), new Person(”coco”)] assert persons .name == [“ocean”, “coco”] assert persons *.getGender() == [“Male”, “Female”]
    17. 17. Copyright © 2001-2006 Infor Global Solutions Closure: 终极代码重用 ArrayList persons = … for(Person person : persons) { System.out.println(person.getName()); } persons.each {it -> println it.name }
    18. 18. Copyright © 2001-2006 Infor Global Solutions 远远不止这些哦。。。 Builder Meta Programming Groovylet GSP GRails Scriptom Griffon GMaven Gant GSQL GORM Tellurium http://groovy.codehaus.org/
    19. 19. Thanks

    ×