SlideShare una empresa de Scribd logo
1 de 31
Descargar para leer sin conexión
T.Yamamoto 2009/07/24 @Nagoya




def speaker = new Cast(name:”T.Yamamoto”,version:”GN-2009-07-24”)
(              )


                    Web
        90%Grails
JGGUG(                   )
  Grails                9-11
 Grails Acegi Plugin



http://d.hatena.ne.jp/mottsnite/
def name='World'                       def list = ["Hello", " ", "World"]
println "Hello $name!"                 list.each{
                                         print it
                                       }

class Greet {
  def name
  Greet(who) { name = who[0].toUpperCase() +who[1..-1] }
  def salute() { println "Hello $name!" }
}
def g = new Greet('world')
// create object
g.salute()
import java.util.Date;                       }                                             return this.black;
                                             public Integer getColorId() {                 }
public class Color {                           return this.colorId;                        public void setBlack(String black) {
 private Integer colorId;                    }                                               this.black = black;
 private String colorName;                   public void setColorId(Integer colorId) {     }
 private String cyan;                          this.colorId = colorId;                     public String getRgb() {
 private String magenta;                     }                                               return this.rgb;
 private String yellow;                      public String getColorName() {                }
 private String black;                         return this.colorName;                      public void setRgb(String rgb) {
 private String rgb;                         }                                               this.rgb = rgb;
 private String sysIpaddress;                public void setColorName(String               }
 private Date sysLastmodified;               colorName) {                                   public String getSysIpaddress() {
 private Integer sysUid;                       this.colorName = colorName;                   return this.sysIpaddress;
 public Color(Integer colorId, String        }                                             }
colorName, String cyan,                      public String getCyan() {                     public void setSysIpaddress(String
    String magenta, String yellow, String      return this.cyan;                         sysIpaddress) {
black, String rgb,                           }                                               this.sysIpaddress = sysIpaddress;
    String sysIpaddress, Date                public void setCyan(String cyan) {            }
sysLastmodified, Integer sysUid) {              this.cyan = cyan;                           public Date getSysLastmodified() {
   this.colorId = colorId;                   }                                               return this.sysLastmodified;
   this.colorName = colorName;               public String getMagenta() {                  }
   this.cyan = cyan;                           return this.magenta;                        public void setSysLastmodified(Date
   this.magenta = magenta;                   }                                           sysLastmodified) {
   this.yellow = yellow;                     public void setMagenta(String magenta) {        this.sysLastmodified = sysLastmodified;
   this.black = black;                         this.magenta = magenta;                     }
   this.rgb = rgb;                           }                                             public Integer getSysUid() {
   this.sysIpaddress = sysIpaddress;         public String getYellow() {                     return this.sysUid;
   this.sysLastmodified = sysLastmodified;       return this.yellow;                         }
   this.sysUid = sysUid;                     }                                             public void setSysUid(Integer sysUid) {
 }                                           public void setYellow(String yellow) {          this.sysUid = sysUid;
 public Color() {}                             this.yellow = yellow;                       }
 public Color(Integer colorId) {             }                                           }
   this.colorId = colorId;                   public String getBlack() {
class Color {
                          Integer colorId
                          String colorName
                          String cyan,magenta,yellow,black,rgb
                          String sysIpaddress
                          Date sysLastmodified
                          Integer sysUid
                        }


class Color {
  Integer colorId, sysUid
  String colorName,cyan,magenta,yellow,black,rgb,sysIpaddress
  Date sysLastmodified
}
String name = 'World'
  ↓
def name='World'

class Dog {
  def say(){ // ←
    “Garuuuuu”
  }
}
GString




       """ ${str.size()}
$str

"""
//
def someMethod(num,clo){ clo(num) }              { println it }       0       1
                                              { -> println 300 }          0
//                                             { a -> println a }         1
def clo = { println "             "+it }
                                             { a=2 -> println a }
def clo2 = {one,two="       "->              { a,b -> println a+b }
  println "             ${one}     ${two}"   { int a -> println a }
}
clo 1 //
clo2 2,1 //
//
someMethod(1,clo)
someMethod(2,clo2)
def pattern = "d{3}-d{4}" //
def text = "633-0412" //
println text ==~ pattern // "true"
def m = text =~ pattern
println m.matches() // "true"

p = ~/d{3}-d{4}/
m = p.matcher(text)
println m.matches() // "true"
[1,2,3] + [1] == [1,2,3,1]
[1,2,3] << 1 == [1,2,3,1]
                                       def list = [0,1,2]
[1,2,3,1] - [1] == [2,3]
                                       list[-1] == 2
                                       assert list[-1..0] == list.reverse()
[1,[2,3]].flatten() == [1,2,3]
                                       assert list == [list.head()] + list.tail()
[1,2,3].reverse() == [3,2,1]
                                       //
[1,2,3].collect{ it+3 } == [4,5,6]
[1,2,3,1].unique()      == [1,2,3]     list.each{println it}
[4,2,1,3].findAll{it%2 == 0} == [4,2]

[1,2,3,4].sum()    == 10
[4,2,1,3].sort()   == [1,2,3,4]
//                       ....
def map = [:]//       map.each { entry ->
                        println entry.key
map.name="        "
                        println entry.value
map['age']=20         }
                      map.each { k, v ->
println map['name']     println "$k $v"
println map.age       }
                      for (entry in map) {
                        println "$entry.key $entry.value"
                      }
assert (0..10).contains(5)

assert (0.0..10.0).containsWithinBounds(3.5)

for (item in 0..10) { println item }

for (item in 10..0) { println item }

(0..<10).each { println it }
def file = new File('data.csv')       //
//
                                     file.eachLine { line ->
file.withWriter('UTF-8'){ writer ->     println line
   writer << ''' ,                   }
      ,90
      ,78                            //
      ,75                            file.splitEachLine(',') {list ->
      ,65                              println list[0]
'''                                  }
}

//
println file.text
<html>
                                  <head>
import groovy.xml.*                <title>Page title</title>
def page = new MarkupBuilder()    </head>
page.html{                        <body>
  head {title 'Page title'}        <div>
  body {                             <li>No.1</li>
    div {                            <li>No.2</li>
      (1..5).each{n->                <li>No.3</li>
        li "No.$n"                   <li>No.4</li>
      }                              <li>No.5</li>
    }                              </div>
  }                               </body>
}                                </html>
class IntCodec {
        static String encode(Integer self){self.toString()}
        static Integer decode(String self){self.toInteger()}
      }
      use(IntCodec){
        244.encode()
        "244".decode()
      }




Integer.metaClass.encode << {delegate.toString()}
String.metaClass.decode << {delegate.toInteger()}
244.encode().decode()
//
Integer.metaClass.methodMissing << {
  String name, Object args ->
  Math."$name"(delegate)
}
println 3.sin()
println 3.cos()
Gaelyk
Grails/Groovy
http://www.jggug.org/

Más contenido relacionado

La actualidad más candente

Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional ProgrammingDmitry Buzdin
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeMongoDB
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014Henning Jacobs
 
Fertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureFertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureMike Fogus
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. ExperienceMike Fogus
 
Code as data as code.
Code as data as code.Code as data as code.
Code as data as code.Mike Fogus
 
Rデバッグあれこれ
RデバッグあれこれRデバッグあれこれ
RデバッグあれこれTakeshi Arabiki
 
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
 
Cycle.js: Functional and Reactive
Cycle.js: Functional and ReactiveCycle.js: Functional and Reactive
Cycle.js: Functional and ReactiveEugene Zharkov
 
Rのスコープとフレームと環境と
Rのスコープとフレームと環境とRのスコープとフレームと環境と
Rのスコープとフレームと環境とTakeshi Arabiki
 
Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Baruch Sadogursky
 
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、GaelykでハンズオンTsuyoshi Yamamoto
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1Ke Wei Louis
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeStripe
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeMongoDB
 
Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQLPeter Eisentraut
 

La actualidad más candente (19)

Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional Programming
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014
 
Fertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureFertile Ground: The Roots of Clojure
Fertile Ground: The Roots of Clojure
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. Experience
 
Code as data as code.
Code as data as code.Code as data as code.
Code as data as code.
 
ES6 in Real Life
ES6 in Real LifeES6 in Real Life
ES6 in Real Life
 
Rデバッグあれこれ
RデバッグあれこれRデバッグあれこれ
Rデバッグあれこれ
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
 
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
 
Cycle.js: Functional and Reactive
Cycle.js: Functional and ReactiveCycle.js: Functional and Reactive
Cycle.js: Functional and Reactive
 
Rのスコープとフレームと環境と
Rのスコープとフレームと環境とRのスコープとフレームと環境と
Rのスコープとフレームと環境と
 
Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014
 
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
 
Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQL
 

Destacado

groovyプラプラとか「はやい、はやいよ」
groovyプラプラとか「はやい、はやいよ」groovyプラプラとか「はやい、はやいよ」
groovyプラプラとか「はやい、はやいよ」Tsuyoshi Yamamoto
 
G*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョンG*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョンTsuyoshi Yamamoto
 
Grailsx@ロンドンへ行ってきた報告。
Grailsx@ロンドンへ行ってきた報告。Grailsx@ロンドンへ行ってきた報告。
Grailsx@ロンドンへ行ってきた報告。Tsuyoshi Yamamoto
 
「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」
「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」
「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」Tsuyoshi Yamamoto
 
G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~Tsuyoshi Yamamoto
 
Groovy Grails eXchage 2014 報告
Groovy Grails eXchage 2014 報告Groovy Grails eXchage 2014 報告
Groovy Grails eXchage 2014 報告Tsuyoshi Yamamoto
 
JJUG CCC 20150411 grails3 Spring-boot
JJUG CCC 20150411 grails3 Spring-bootJJUG CCC 20150411 grails3 Spring-boot
JJUG CCC 20150411 grails3 Spring-bootTsuyoshi Yamamoto
 

Destacado (11)

groovyプラプラとか「はやい、はやいよ」
groovyプラプラとか「はやい、はやいよ」groovyプラプラとか「はやい、はやいよ」
groovyプラプラとか「はやい、はやいよ」
 
JGGUG 2011-02 LT
JGGUG 2011-02 LTJGGUG 2011-02 LT
JGGUG 2011-02 LT
 
G*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョンG*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョン
 
Grailsx@ロンドンへ行ってきた報告。
Grailsx@ロンドンへ行ってきた報告。Grailsx@ロンドンへ行ってきた報告。
Grailsx@ロンドンへ行ってきた報告。
 
「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」
「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」
「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」
 
G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~
 
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
 
Gaelyk
GaelykGaelyk
Gaelyk
 
JGGUG grails-spring-boot
JGGUG grails-spring-bootJGGUG grails-spring-boot
JGGUG grails-spring-boot
 
Groovy Grails eXchage 2014 報告
Groovy Grails eXchage 2014 報告Groovy Grails eXchage 2014 報告
Groovy Grails eXchage 2014 報告
 
JJUG CCC 20150411 grails3 Spring-boot
JJUG CCC 20150411 grails3 Spring-bootJJUG CCC 20150411 grails3 Spring-boot
JJUG CCC 20150411 grails3 Spring-boot
 

Similar a はじめてのGroovy

Team public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfTeam public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfDEEPAKSONI562
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tourSimon Proctor
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tourSimon Proctor
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokusHamletDRC
 
Ast transformations
Ast transformationsAst transformations
Ast transformationsHamletDRC
 
Help I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfHelp I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfmail931892
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldBTI360
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodecamp Romania
 
in this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfin this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfmichardsonkhaicarr37
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)HamletDRC
 
Type script by Howard
Type script by HowardType script by Howard
Type script by HowardLearningTech
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by HowardLearningTech
 
Howard type script
Howard   type scriptHoward   type script
Howard type scriptLearningTech
 

Similar a はじめてのGroovy (20)

Introduzione a C#
Introduzione a C#Introduzione a C#
Introduzione a C#
 
Presentatie - Introductie in Groovy
Presentatie - Introductie in GroovyPresentatie - Introductie in Groovy
Presentatie - Introductie in Groovy
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
Team public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfTeam public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdf
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
Help I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfHelp I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdf
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
in this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfin this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdf
 
Groovy
GroovyGroovy
Groovy
 
Solid
SolidSolid
Solid
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)
 
Type script by Howard
Type script by HowardType script by Howard
Type script by Howard
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
 
Howard type script
Howard   type scriptHoward   type script
Howard type script
 
Oop lecture9 13
Oop lecture9 13Oop lecture9 13
Oop lecture9 13
 

Más de Tsuyoshi Yamamoto

G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門Tsuyoshi Yamamoto
 
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」Tsuyoshi Yamamoto
 
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」Tsuyoshi Yamamoto
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Tsuyoshi Yamamoto
 
JGGUG Camp 2009 いっぽう熱海では、
JGGUG Camp 2009 いっぽう熱海では、JGGUG Camp 2009 いっぽう熱海では、
JGGUG Camp 2009 いっぽう熱海では、Tsuyoshi Yamamoto
 
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! GrailsプラグインTsuyoshi Yamamoto
 
GrailsでSpringをGroovyにしよう!
GrailsでSpringをGroovyにしよう!GrailsでSpringをGroovyにしよう!
GrailsでSpringをGroovyにしよう!Tsuyoshi Yamamoto
 
Grails-1.1を斬る!~Grails-1.1からのチーム開発~ in Tokyo
Grails-1.1を斬る!~Grails-1.1からのチーム開発~ in TokyoGrails-1.1を斬る!~Grails-1.1からのチーム開発~ in Tokyo
Grails-1.1を斬る!~Grails-1.1からのチーム開発~ in TokyoTsuyoshi Yamamoto
 

Más de Tsuyoshi Yamamoto (15)

Grailsx@London 2011 報告
Grailsx@London 2011 報告Grailsx@London 2011 報告
Grailsx@London 2011 報告
 
Grails 2.0.0.M1の話
Grails 2.0.0.M1の話 Grails 2.0.0.M1の話
Grails 2.0.0.M1の話
 
Grails 1.4.0.M1 メモLT
Grails 1.4.0.M1 メモLTGrails 1.4.0.M1 メモLT
Grails 1.4.0.M1 メモLT
 
G * magazine 1
G * magazine 1G * magazine 1
G * magazine 1
 
G * magazine 0
G * magazine 0G * magazine 0
G * magazine 0
 
Grailsのススメ(仮)
Grailsのススメ(仮)Grailsのススメ(仮)
Grailsのススメ(仮)
 
G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門
 
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
第3回Grails/Groovy勉強会名古屋「Grails名古屋座談会」
 
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
 
JGGUG Camp 2009 いっぽう熱海では、
JGGUG Camp 2009 いっぽう熱海では、JGGUG Camp 2009 いっぽう熱海では、
JGGUG Camp 2009 いっぽう熱海では、
 
ExtJS勉強会@名古屋
ExtJS勉強会@名古屋ExtJS勉強会@名古屋
ExtJS勉強会@名古屋
 
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
第4回 g* ワークショップ はじめてみよう! Grailsプラグイン
 
GrailsでSpringをGroovyにしよう!
GrailsでSpringをGroovyにしよう!GrailsでSpringをGroovyにしよう!
GrailsでSpringをGroovyにしよう!
 
Grails-1.1を斬る!~Grails-1.1からのチーム開発~ in Tokyo
Grails-1.1を斬る!~Grails-1.1からのチーム開発~ in TokyoGrails-1.1を斬る!~Grails-1.1からのチーム開発~ in Tokyo
Grails-1.1を斬る!~Grails-1.1からのチーム開発~ in Tokyo
 

Último

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 

Último (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 

はじめてのGroovy

  • 1. T.Yamamoto 2009/07/24 @Nagoya def speaker = new Cast(name:”T.Yamamoto”,version:”GN-2009-07-24”)
  • 2. ( ) Web 90%Grails JGGUG( ) Grails 9-11 Grails Acegi Plugin http://d.hatena.ne.jp/mottsnite/
  • 3.
  • 4.
  • 5.
  • 6. def name='World' def list = ["Hello", " ", "World"] println "Hello $name!" list.each{ print it } class Greet { def name Greet(who) { name = who[0].toUpperCase() +who[1..-1] } def salute() { println "Hello $name!" } } def g = new Greet('world') // create object g.salute()
  • 7.
  • 8. import java.util.Date; } return this.black; public Integer getColorId() { } public class Color { return this.colorId; public void setBlack(String black) { private Integer colorId; } this.black = black; private String colorName; public void setColorId(Integer colorId) { } private String cyan; this.colorId = colorId; public String getRgb() { private String magenta; } return this.rgb; private String yellow; public String getColorName() { } private String black; return this.colorName; public void setRgb(String rgb) { private String rgb; } this.rgb = rgb; private String sysIpaddress; public void setColorName(String } private Date sysLastmodified; colorName) { public String getSysIpaddress() { private Integer sysUid; this.colorName = colorName; return this.sysIpaddress; public Color(Integer colorId, String } } colorName, String cyan, public String getCyan() { public void setSysIpaddress(String String magenta, String yellow, String return this.cyan; sysIpaddress) { black, String rgb, } this.sysIpaddress = sysIpaddress; String sysIpaddress, Date public void setCyan(String cyan) { } sysLastmodified, Integer sysUid) { this.cyan = cyan; public Date getSysLastmodified() { this.colorId = colorId; } return this.sysLastmodified; this.colorName = colorName; public String getMagenta() { } this.cyan = cyan; return this.magenta; public void setSysLastmodified(Date this.magenta = magenta; } sysLastmodified) { this.yellow = yellow; public void setMagenta(String magenta) { this.sysLastmodified = sysLastmodified; this.black = black; this.magenta = magenta; } this.rgb = rgb; } public Integer getSysUid() { this.sysIpaddress = sysIpaddress; public String getYellow() { return this.sysUid; this.sysLastmodified = sysLastmodified; return this.yellow; } this.sysUid = sysUid; } public void setSysUid(Integer sysUid) { } public void setYellow(String yellow) { this.sysUid = sysUid; public Color() {} this.yellow = yellow; } public Color(Integer colorId) { } } this.colorId = colorId; public String getBlack() {
  • 9. class Color { Integer colorId String colorName String cyan,magenta,yellow,black,rgb String sysIpaddress Date sysLastmodified Integer sysUid } class Color { Integer colorId, sysUid String colorName,cyan,magenta,yellow,black,rgb,sysIpaddress Date sysLastmodified }
  • 10.
  • 11. String name = 'World' ↓ def name='World' class Dog { def say(){ // ← “Garuuuuu” } }
  • 12.
  • 13.
  • 14. GString """ ${str.size()} $str """
  • 15. // def someMethod(num,clo){ clo(num) } { println it } 0 1 { -> println 300 } 0 // { a -> println a } 1 def clo = { println " "+it } { a=2 -> println a } def clo2 = {one,two=" "-> { a,b -> println a+b } println " ${one} ${two}" { int a -> println a } } clo 1 // clo2 2,1 // // someMethod(1,clo) someMethod(2,clo2)
  • 16. def pattern = "d{3}-d{4}" // def text = "633-0412" // println text ==~ pattern // "true" def m = text =~ pattern println m.matches() // "true" p = ~/d{3}-d{4}/ m = p.matcher(text) println m.matches() // "true"
  • 17.
  • 18. [1,2,3] + [1] == [1,2,3,1] [1,2,3] << 1 == [1,2,3,1] def list = [0,1,2] [1,2,3,1] - [1] == [2,3] list[-1] == 2 assert list[-1..0] == list.reverse() [1,[2,3]].flatten() == [1,2,3] assert list == [list.head()] + list.tail() [1,2,3].reverse() == [3,2,1] // [1,2,3].collect{ it+3 } == [4,5,6] [1,2,3,1].unique() == [1,2,3] list.each{println it} [4,2,1,3].findAll{it%2 == 0} == [4,2] [1,2,3,4].sum() == 10 [4,2,1,3].sort() == [1,2,3,4] // ....
  • 19. def map = [:]// map.each { entry -> println entry.key map.name=" " println entry.value map['age']=20 } map.each { k, v -> println map['name'] println "$k $v" println map.age } for (entry in map) { println "$entry.key $entry.value" }
  • 20. assert (0..10).contains(5) assert (0.0..10.0).containsWithinBounds(3.5) for (item in 0..10) { println item } for (item in 10..0) { println item } (0..<10).each { println it }
  • 21. def file = new File('data.csv') // // file.eachLine { line -> file.withWriter('UTF-8'){ writer -> println line writer << ''' , } ,90 ,78 // ,75 file.splitEachLine(',') {list -> ,65 println list[0] ''' } } // println file.text
  • 22.
  • 23.
  • 24. <html> <head> import groovy.xml.* <title>Page title</title> def page = new MarkupBuilder() </head> page.html{ <body> head {title 'Page title'} <div> body { <li>No.1</li> div { <li>No.2</li> (1..5).each{n-> <li>No.3</li> li "No.$n" <li>No.4</li> } <li>No.5</li> } </div> } </body> } </html>
  • 25. class IntCodec { static String encode(Integer self){self.toString()} static Integer decode(String self){self.toInteger()} } use(IntCodec){ 244.encode() "244".decode() } Integer.metaClass.encode << {delegate.toString()} String.metaClass.decode << {delegate.toInteger()} 244.encode().decode()
  • 26. // Integer.metaClass.methodMissing << { String name, Object args -> Math."$name"(delegate) } println 3.sin() println 3.cos()
  • 27.
  • 28.
  • 30.