ã¢ããGroovy系女ååããããï¼ã¤ã®å¿å¾
ããã«ã¡ã¯ãGroovyã§éãã§ããorangecloverã§ããç§ã¯JRubyãJythonãScalaã
Clouserã®ç¥èãããã¾ããããææã«é¢ãã¦ãç´ äººã§ãã
ä»åã¯ãã¢ããGroovy女ååã磨ãããã®4ã¤ã®å¿å¾ãçããã«ãæããããã¨æãã¾ãã
1. ããã¦2ã3 ä¸ä»£åã®Groovyã使ã
ããã¦2ã3 ä¸ä»£åã使ãããã«ãã¾ããããããã¦åå¼·ä¼ã®å ´ã§å¥½ã¿ã®ç·ãããã話
ããããããã¨ãããããã¨ãããGroovyãããã£ã¦ã¿ã¾ããããããã¦ããããï¼ã
ã®Groovyæ¬å½ã«ã§ãã§ã¼ã ã«ã¤ããã§ããã©ããããï¼ãã¨è¨ã£ã¦ãç·ã«ãã©ãããã®
ï¼ãã¨è¨ããã¾ããããè¨ãããããã大æåããGroovyã¨ã詳ãããªãã¦ããï¼ ãã£
ã¨1.6.5系使ã£ã¦ããã§ããã©ããï¼Groovy ã¤ã³ã»ã¢ã¯ã·ã§ã³ã®éãã«æ¸ãã¦ãã®ã«
string.eachMatchã®æåãå¤ãªãã§ãã
ããã·ãã·ããããï¼æï¼ãã¨è¨ãã¾ãããã
ã ãããã®ç·ã¯æ°ããVersionã使ããããç¿æ§ãããã®ã§ãå¤ãã£ãã¨ãã¦ã1.7ç³»ã
使ã£ã¦ããã¯ãã§ãã
ããã§ç·ããæ°ããVersionã«ããªãã®ï¼ãã¨è¨ã£ã¦ããã¯ãï¼è¨ã£ã¦ããªã空æ°ãèª
ããªãç·ã¯ãã®æç¹ã§ã¬ã³ç¡è¦OKï¼ãããè¨ããããããªãã¯ããªãããªããããï¼æè¿
Groovy2.0ã人æ°ãªãã§ããã¼!?ããã£ã¦ã©ããªãã§ãããï¼ãªããã¯ãã¼ã¸ã£ã®å¼·åã
ããããã¡ã½ããå¼ã³åºãã®æ¬å¼§ãæ¸ããªãã¦ããã¨ããä¾å¤ã®ãã«ããã£ããã¨ãã
æ°ããã®ä½¿ã£ã¦ã¿ãããã§ããã©ããããªããããã!!ç§ããããã¼ãªã³â
ãã¨è¿ãã¾
ããããã¨ç·ã¯ã1.8.0ã§ããï¼ 1.9ã¯beta-1ã ãã2.0ã¯ã¯ã¾ã åºã¦ãªããããã¤åºã
ãã決ã¾ã£ã¦ãªãããæ¬å½ã«è¯ãããããªãã¿ããã ããããã¨Groovy ã¤ã³ã»ã¢ã¯ã·ã§
ã³ã¯1.5.4ã®è¨è¿°ã ãã1.6.0ããã¯ãeachMatchã®ä»æ§ãå¤ãã£ã¦ããããããã¯ã
matchã¨æ¸ãå¿
è¦ããããã ããã¨ããããGroovyåå¼·ä¼ããã§ããããã¨(ry ãã¨ãã
話ã«ãªã£ã¦ã次ã®ä¼ã¿ã®æ¥ã«Groovyåå¼·ä¼ã«è¡ããã¨ã«ãªãã¨ããããã§ãã
ããªãã®å¥³ååãé«ããã°ãç·ããã¢ããã§Groovyãæãã¦ããã¦ããã®å¾ææ°ã®ãã½
ã³ã³ã¾ã§è²·ã£ã¦ããããã!?
2. Classåãã¡ã½ããåã§ã«ã¿ã«ãã使ãã¨ã¢ãã
ããã©ã¼ã³ãã¨ãããã³ãªããªã©ãæ¬é³ãã«ã¿ã«ãã§Classåãã¡ã½ããåãå¤æ°åã«ä½¿
ãã¨ãGroovyã®ç·æ§ã¦ã¼ã¶ã¼ã¯ããªãããã®åã«ã¯ã¤ã¤ãªããããDSLä½ã£ã¦ããããã
ããã¨æã£ã¦ããã¾ãã
def ã¤ã§ã¤(){println "O(â§ââ¦)o"} def ããºã«ã·ã¤(){println "///â///"} def ã¿ã©ã¼ã³(){ println "(ï¿£â½ï¿£;)"} def ãã©ã¼ã³(){println "(ï¿£â½+ï¿£*)*:..。oââï¾ï½¥:,。*:..。oââ"} def ãã³ãª(){ println "ãããããããã¨ããããã¾ã"} ã¿ã©ã¼ã³() ãã©ã¼ã³() ã¤ã§ã¤() ããºã«ã·ã¤()
groovy ã«ã¯ã¤ã¤.groovy (ï¿£â½ï¿£;) (ï¿£â½+ï¿£*)*:..。oââï¾ï½¥:,。*:..。oââ O(â§ââ¦)o ///â///
ã¨ããããã«æ¸ãã¾ããããããã°ã©ãã¯ã½ã¼ã¹ã³ã¼ãã®ã¿ã§ä¼è©±ãããã®ã§ ã«ã¿ã«ã
ãå¤ç¨ãããã¨ã«ãã£ã¦ãç·æ§ã¯ããªããå¯æã§å¥³ã®åãããã¨åéããã¦ãããã®ã§
ããããããã½ã¼ã¹ã³ã¼ããæ¸ãã¨æ¥æ¬èªã¡ã½ããã¯å¥½ã¾ãããªãã¨èãã大å¤æ°ã®ã
ãã°ã©ãã«å«ããã¾ããæ°ã«ããªãããã«ãã¾ãããã
3. ã¨ããããç·ã«ã¯ããã¼ï¼ ãªã«ãã!?ã ç¥ãããç¥ããã¼ãâªãã¨è¨ã£ã¦ãã
åå¼·ä¼ã®æ親ä¼ãªã©ã§ç·ã女æ§ã«è©±ããã¨ã¨ããã°1.8ã®ã¯ãã¼ã¸ã£ã®å¼·åã®è©±ãASTå¤æã®
話ã°ããããã£ã¦ã女æ§ã«ã¨ã£ã¦ã©ãã§ããã話ã°ããã§ããã§ãããã§é©å½ã«ãã¸ãã¼
ãããªãã§ããããï¼ãã¨ããããããããªãã§ããã©ããããã§ããããã¨è¿ãã¦ãã¾
ãã¨ããããã®ç·ãããã®å¥³ãã¯ãã¼ã¸ã£ãç¥ããªããªãã¨æ°ãã¤ãã¦ãã¾ãã¾ãã
ãã¡å¥³ã ã¨ãã¬ããçµããã§ãã
ããã¯ç¡æå³ã«ãã³ã·ã§ã³ãããã¦ãããã¼ï¼ ãªã«ãã!?ã ç¥ãããç¥ããã¼ãâªã
ã¨è¨ã£ã¦ããã®ãæ£è§£ããã¨ãèå³ããªã話é¡ã§ãããã³ã·ã§ã³ã¨ç©æ¥µæ§ã§ãã®å ´ãä¹ã
åãã¾ããããç©æ¥µçã«è©±ãèãã¦ããã女æ§ã«ç·ã¯å¼±ãã®ã§ãã
ããããã¨è©±ãèãããã¨ããGroovy1.8ã§ã¯ã³ãã³ããã§ã¼ã³ãå°å
¥ããã¦ãè¤æ°ã¡
ã½ãããã¯ãã¼ã¸ã£ãååä»ãå¼æ°ã¨ä¸ç·ã«æ©è½ãã¦ãããã«å³å´ã«é£ãã¦ãããã¨ã
ã§ãã¦ããã¾ãå©ç¨ããã¨DSLãä½ãããã§ããï¼ãè¦ããããï¼ãã¡ã¢ã¡ã¢ï¼ãã¨ã³ã¡
ã³ãããã°ãã¼ãã§ã¯ããç¶ãã¦é ã«æãããã¦ããããåãã¤ã¤ããã¥ã³ãã¥ã³ãã¥ã³
ï¼ ãã¥ã³ãã¥ã³ãã¥ã³ï¼ãã¨è¨ã£ã¦ããã©ãããã®ï¼ãã¨ç·ã«è¨ãããã®ãã¢ãªããã
ã§ãç§ã®$1ã®è¨é²ãã¦ããã§ããã¾ãã£âãã¨è¨ãã°å¥³ååã¢ããï¼ããã§ã¾ãç·ã¯ãã
ã®åãããããã¦ã«ã¯ã¤ã¤ãã!?ãã¨æã£ã¦ããã¾ããç§ã¯JRubyãJythonãScalaã
Clouserããªã«ãã§ãã¾ãããããããããã¯ããã¯ã使ãã°JavaVMä¸ã®æ°è¨èªãã§ããª
ããããªãã«å¥³ã®ã»ããã¢ãããããã®ã§ããç·ã¯åªè¶æã«æµ¸ãããã§ããããã
4. Groovy 1.8 ã使ããªã女ãã¢ãã¼ã«ãã
åå¼·ä¼ã«åå ããããçã£å
ã«Groovy 1.8ã使ã£ã¦ã人ãæ¢ãã¦ããã¼ãï¼ç§Groovy 1.8
使ããªããã§ãããããï¼æ²ï¼ãã¨è¨ãã¾ããããããã¨ã»ã¼100ãã¼ã»ã³ããã©ããã¦
ï¼ä½¿ããªãã®ï¼ãã¨èãããã®ã§ããå«ããããªãã使ããããã©ã使ããªããã§ãã£
(ã¦ã«ã¦ã«)ãã¨è¿çãã¾ããããããã§ã¾ã100ãã¼ã»ã³ããã©ããã¦ï¼å«ããããªã®ã«
ã©ããã¦ä½¿ããªãã®ï¼ãã¨èãããã®ã§ããã¤ããã¦3ã5ç§ã»ã©éãããã¦ãããã½ã
ã¨ããè¨ãã¾ãããâ¦â¦ã ã£ã¦ãâ¦â¦ã ã£ã¦ã1.8使ã£ãã£ã intã«nullããããªããã
ãªãã§ãããã£ï¼intãããããã§ãã
ï¼1.7ã¾ã§ã¯ãã¾ã Integerã¨ç価ã ã£ãã®ã«ãã
ãï¼ã°ã¹ã³)ãæ±ãå¤ãã£ã¡ãããã§ããâ¦â¦ãã¨èº«ãéããã¦è¨ãã®ã§ãã
ãã®ç¬éãããªãã®å¥³ååãã¢ãããã¾ãããã£ã¨ç·åã¯ããªãã¦åªããGroovyããã®ã
ããªã³ãªãã ããï¼ çµ¶å¯¾ã«ã²ãããã¦ãããï¼ ã³ã¤ãã¯ä¿ºã®å¥³ã ï¼ãã¨å¿ã®ãªãã§èªãã
ããªãã«æãè¾¼ãã¯ãã§ããæä¸ã®ç·åã¨ä»ãåããã¨ã«ãªã£ããããããªãã¨ã¯å¿ãã¦
好ããªã ãGroovyã使ã£ã¦å¤§ä¸å¤«ã§ããã使ããªãããããªãã£ãã£ãï¼ãã¨è¨ãããã
ã大ä¸å¤«ã«ãªã£ã(ã¤ã§ã¤)ãã¨ãã æ
£ãã¾ãããâ ãããæãã¦ããã¦æ¬å½ã«ãããã¨
ã(ãã³ãª)ãã¨è¨ã£ã¦ããã°OKã§ãã
â»ããã¾ã§ããã¿ã§ãããGroovyã¦ã¼ã¶ã®æè¦ã代表ãããã®ã§ããå人ã®è¶£å³ã§ãããã¾ããã