こんにちはGroovy

download こんにちはGroovy

If you can't read please download the document

description

第1回プログラミングGroovy勉強会(大阪)のスライドです。

Transcript of こんにちはGroovy

  • 1. Groovy #ghello Groovy 1 Groovy @irof

2. #ghello? 3. 4. #ghello

  • 1Tweet

5. Hello WorldOK

  • Hello

6. 7. 8. 9. 10. #1 @kazuchika 11. String#toURI()

  • GDK
  • Groovy JDK

12. GROOVY P.177 URI 13. Desktop.desktop.browse(URI)

  • class java.awt.Desktop
  • Java

Desktop#brouse(URI)

  • Java(ry

static Desktop getDesktop()

  • getter

14. #2 @kiy0taka 15. SwingBuilder

  • Builder
  • Swing

16. GROOVY P.139 17. #3 @nobeans groovy:000> hello ===> null 18. propertyMissing(String)

  • MissingPropertyException

19. methodMissing 20. http://groovy.codehaus.org/Using+methodMissing+and+propertyMissing 21. [h,e,l*2,o]

  • List
  • GROOVY P.82

22.

  • add

23. java.util.ArrayList 24. [h,e,l*2,o]

  • String * 2

25. assert a * 3 == aaa 26. * multiply(Number)

  • l.multiply(2)

27. List#join()

  • List

assert [a,b,c].join() == abc assert [a,b,c].join(,) == a,b,c 28. println(String)

  • Object

29. System.out.println

3 30. #4 @fumokmm groovy:000> Hello World ===> null 31. String#toURL()

32. URL#getText()

  • URL
  • Java

33. API 34. Groovy

  • FilegetTexteachLine

35. Closure (P.71)

  • def clos = {arg -> println arg}

36. ->

  • it

37. def clos = {println it}

38. String#find( Pattern,Closure )

  • ~ (P.116)

39. /hoge/ (P.67)

  • ~'hoge'

ClosureitArrayList

  • String

40. Groovy1.6 41. [33..43]

  • assert 'abcde'[3] == 'd'
  • 33..43 (Range)

42. assert 'abcde'[2..4] == 'cde' 43. #5 @orange_clovergroovy:000> Hello World ===> null 44. Object.each(Closure)

  • Closure

45. CollectionObject 46. Closure

  • Object.each({closure})

47. Object.each(){closure} 48. Object.each{closure} 49. 50. #6 @kyon_mm groovy:000> [echo] Hello World ===> org.apache.tools.ant.taskdefs.Echo@259 27275 51. AntBuilder

  • Ant
  • Builder (P.134)

52. echo(hello)

Gant (P.233) 53. #7 @bluepapa32 54. SwingBuilder

  • Frame

55. 56. #8 @irof groovy:000> ( ) Hello, world! ===> null 57. JsonSlurper#parseText

  • JSON

58.

  • {"k1":"Hello","k2":"world"}
  • HashMap

59. [k1:"Hello", k2:"world"] 60. Object#with(Closure)

  • (P.181)

61. Closurewith 62. VB.NET With-End With 63. GString

  • String

64.

  • println "${k1}, ${k2}!"

GStringwithMap

  • [k1:"Hello", k2:"world"]

65. #9 @mike_neck groovy:000> () Hello World ===> null 66. String#execute()

67. Mac say 68. #10 @kimukou_26 groovy:000> () Hello world ===> null 69. Java

  • substring indexOf

70. new URL(String)

  • String#toURL()

URL#getText Groovy 71. #11 @tyuki39 groovy:000> () Hello World ===> [Ljava.lang.reflect.Field;@29cb2 795 72.

  • C.class.fields, Field.name
  • Class#getFields(),Field#getName()

Field[].each {} 73. it[0..4] + ' ' + it[5..-1]

74. -1 75. #12 @nightmare_tim groovy:000> () Hello World! ===> null 76. for (P.108)

  • for(i in 0..10)

77. List

  • def a=[1,2,3]

78. a[4] = 9 79. assert a == [1,2,3,null,9]

  • List#add(4, 9)

80. #13 @backpaper0 PS> () hello world PS> 81.

  • -e

82. Windows 83. #14 @uehaj groovy:000> () Hello, World ===> null 84.

  • Class#getResource URL

85. getText()

  • text

86. Javadoc 87. #15 @nagai_masato 88. Object#each(Closure)

89. String 90. each 1Closure

  • abc.each{print it*2}
  • aabbcc

91. String#toInteger()

92. #16 @toby55kij groovy:000> () Hello World ===> {Hello=World} 93. JsonBuilder

  • JSON

94. BuilderMap 95. Closure 96. Map

  • LinkedHashMap

97. Map.each(Closure)

  • Closure1
  • Map$Entry
  • [a:1].each{println it}

Closure2

  • Key,Value
  • [a:1].each{k,v->println k+v}

98. #17 @nobusue groovy:000> () Hello World! ===> null 99. JavaScript

  • ScriptEngineManagerJava

100. JavaGroovy 101. #18 @primnum groovy:000> () Hello World ===> 0..10 102. Object#eachWithIndex(Closure)

  • 2Closure

groovy:000> 'abc'.eachWithIndex{a, b->println "val:$a, index:$b"} val:a, index:0 val:b, index:1 val:c, index:2 ===> abc 103. #19 @torazuka groovy:000> () HELLO, WORLD!! ===> null 104. String#getAt

  • int, IntRange, EmptyRange, Range,Collection

105. 106. getAt assert "Oh! Well, Lord!"[1,5,6,7,11] == "hello" 107. #20 @bikisuke groovy> Hello World JUnit 4 Runner, Tests: 1, Failures: 0, Time: 114 108. Spock 1.8 @Grab('org.spockframework:spock-core:0.5-groovy-1.8') @GrabExclude('org.codehaus.groovy:groovy-all') class g extends spock.lang.Specification{ def"h"(){expect:println'Hello World'}} 109. @Grab

110. Grape (P.194) 111.

112. Spock (P.241)

  • BDD

113. 114. JUnit 115. JUnit

  • IntelliJ IDEA

116. #21 @masanobuimai groovy> GroovyConsoleHello.World 117. String#capitalize()

  • since 1.7.3

118. 119. 120. 121. 122. main

  • class
  • classmain

package hello class World {} println World.class.name.capitalize() 123. #22 @lemur314 groovy:000> () Hello World ===> null 124. String#reverse()

  • since 1.0

125. #23 touchez_du_bois groovy:000> () println "Hallo, Welt!" ===> null 126. SimpleTemplateEngine

  • template
  • make MapOK

P.262

  • Groovy

127. #24 @tyama groovy> ()hello world! 128. DSL

  • ={}, ={}
  • it
  • null
  • def ,

( );; ( )

  • ;;

129. ={a,b->...}

  • , ( )

130. ( , ( ))

  • null

131. #25 @kanemu groovy:000>() hello,world! ===> {a=h, b=e, c=l, d=l, e=o, f=,, g=w, h=o, i=r, j=l, k=d, l=!} 132. Map#sort()

  • Since 1.7.2

133. Map#sort(Closure)

  • [:].sort { a, b -> a.value b.value }

Map#sort(Comparator)

  • [:].sort({ a, b -> a[-1] b[-1] } as Comparator)

134. #26 @osimajp 135. Object#each(Closure)

  • Collection (P.85)

136. Object (P.183)

  • any, every, each

137. collect, find, findAll 138. #27 @fumokmm groovy:000> () Hello World ===> null 139. 140. 141. #28 @kazuchikagroovy:000> (;) Thanks for joining #ghello! ===> null 142. new Event(name:"#ghello")

  • (P.49)

143. 144. ... 145. ... 146. ... 147. ... 148. ... 149. #ghello