DroidKaigi2018ã§åç¥ããã¦ããKotlin Fest2018ã«åå ãã¦ãããLTæ ã§ç³ãè¾¼ãã ããæ°åã§æ ãæ¶ãã¦éã«åããªãã£ããå®ã¯10æã«ã¢ã ã¹ãã«ãã ã§éå¬ãããKotlin Conf2018ã«ãåå äºå®ã§ãCfPãåºãã¦ãããéããªãã£ãããã£ã¨å®åãã¤ãã¦æ¥å¹´åãã£ã¬ã³ã¸ããã
æè¿ã¯ã¢ããªã®Kotlinåããã¼ã ã§æ¨ãé²ãã¦ããããä»ã®ã³ã¼ããKotlinãããæ¸ããã¨ã¯ã§ãããããããè¨èªã¬ãã«ã§ããè¯ãã³ã¼ãã«ããã«ã¯ã©ãããã¹ãããKotlinã使ã£ã¦ãã£ã¨è¯ãè¨è¨ã«ããã«ã¯ã©ãããã¹ããã¨èãããã¦ããªãã®ã§åå¼·ãã¦ãããåå¼·ã«ãªãã»ãã·ã§ã³ãå¤ãã£ãã®ã§ã¡ã¢ãæ®ãã¦ãããè³æã¯âã«ãã¹ã¦ããã®ã§ãè¨äºã®èªã¿è¾¼ã¿ãã¹ã ã¼ãºã«ããããã«ãè²¼ããªãã
Kotlin Fest 2018 - 資料一覧 - connpass
Kotlinã§æ¹åããAndroidã¢ããªã®å質ï½ãããããã
Androidã®è©±ã¯ããã¾ããã¾ããã¨ããåºã ãã®ã¨ãããEffective Java第äºçã®å 容ããã¼ã¹ã«Javaã®ãã¹ããã©ã¯ãã£ã¹ãKotlinã§ã¯ã©ã®ããã«æ¸ãæããããããã©ã®ããã«ãã®æ©æµãåãããããã¨ããçºè¡¨å 容ã§é¢ç½ãã£ããããKotlinãæ¸ãã«ã¯Javaã®ç¥èãå¿ è¦ã ã¨è¨ãããããJavaãç¥ãããã®åé¡ãã©ã®ããã«Kotlinã§è§£æ±ºããæ¹æ³ãæä¾ããã¦ããã®ããç¥ãã®ã大åã ãNullå®å ¨ã«æ¸ãããªã©ã¯ãã®ã»ãã®ä¸é¨ã§ãããªãã
Javaã§ã®Builderãã¿ã¼ã³ã¯ãã使ãããææ³ã ããæ¹ãã¦Kotlinã§å¿ è¦ãªã¨ãã¯ããã®ã ãããã¨èããã¨ãã¾ããªããBuilderãã¿ã¼ã³æé«ã®ã¨ãã»ã³ã¹ã¯ã¡ã½ãããã§ã¤ã³ã§ãããã¨ã§ã¯ãªããã¤ã³ã¹ã¿ã³ã¹åæåæã«ä»£å ¥ããå¤ã®ååãé©åã«æ±ºãããããã¨ã¨ãæå³ã®ããã¾ã¨ã¾ãã§ä»£å ¥ãã§ãããã¨ã ã¨ç解ã§ããããããã£ãå¤ããã親ãã¾ãã¦ãããã¿ã¼ã³ãã©ã®ããã«Kotlinãããæ¸ãã¦ããã¹ããã¨ããã®ãèãå§ããã«ã¯æã£ã¦ä»ãã®é¡æã ã£ãã
Kotlinã®dataã¯ã©ã¹ã¯ã¨ã«ããå¼·åãªã®ã ããæ¸ããªãã¦ããã³ã¼ããå¢ããã¨ãããã¨ã¯ãããã ãæé»çã«ç解ãã¦ãããªãã¨ãããªãã³ã¼ããå¢ããã¨ããæå³ã§ããããæè¿Abemaã§equalsãhashCodeé¢æ°ã®ãªã¼ãã¼ã©ã¤ããããæ©ä¼ãããããã®ã¸ãã®åå¼·ãæ¹ãã¦ãã¦ããã®ã ããcompareé¢é£ããã£ã¨åå¼·ããªãã¨ãªã¨æããã
Kotlinã¢ããªã®ãªãã¡ã¯ã¿ãªã³ã°ãã¤ã³ãï½Naoto Nakazato
kotlinã®ããè¯ãæ¸ãæ¹ãç´¹ä»ããã»ãã·ã§ã³ã ã£ããtipséã¨ããæãã§ããã ããï¼ã¨ããå 容ãå¤ãã£ãããæ¡å¼µé¢æ°ãinterfaceå ã«ããã¦ã使ããã¹ã³ã¼ããéå®ããæ¹ãããããã¨ããã®ã¯ãããå ±æã§ãããæ¡å¼µé¢æ°ãè¨èªæ©è½ã¨ãã¦æä¾ãã¦ããå ´åããã¼ã ã®åã ã俺ã®èããæå¼·ã®extentionã¿ãããªãã®ãä¹±ç«ãã¦ã«ãªã¹ã«ãªãããããã³ã¼ãã£ã³ã°ã«ã¼ã«ã§å¼·å¶ããã«ã¯é£ãããããã¨è¨ã£ã¦æ¾ç½®ãã¦ããã¨ãä¼¼ããããªãã®ãå ¨ä½ã¨ãã¦ã¯å¿ è¦ãªããã®ã¾ã§ãç¡ç¨ãªæ±ç¨æ§ããæã£ã¦ä½æãããã¡ã ã¨æãããªã®ã§ãextentionsããã±ã¼ã¸ãªã©ã¯ããããã£ã¬ã¯ããªã«ä½æããã«ãæ©è½ãã¨ã«ããã±ã¼ã¸å ã§éãã¦ããã¹ã¿ã¤ã«ãè¯ããªã¨å ±æããã
ä»ã«ãè³æã®115Pããå§ã¾ããç¶æ 管çã®æ´çã®ä»æ¹ã«ã¤ãã¦ã¯åå¼·ã«ãªã£ãããæ°ççã«æ±ããçµã¿åããæé©è§£ã«ååãã¤ããã®ãä¸çªå¤§å¤ãªã®ã ããª...ã¨æãããEitherãPairã¨ãã£ãã¯ã©ã¹ãä¹±ç¨ããã®ã¯ã«ãªã¹ã¨ã³ã¸ãã¢ãªã³ã°ã®å§ã¾ãã ãè³æã«ãããããã«ç¶æ ãæ°å¼ã§è¡¨ãã¦ãä»®ã«
val state = Either<Pair<A, B?>, C>?
ã®ãããªãã®ãã§ããã¨ãã¦ããä¾ãã°Userã®ç¶æ Aã¨ç»é¢ã®ç¶æ Bããã¤Pairã«ã©ããªæãé©åãªååãã¤ããããã ãããï¼ãããã¯ãã®ã³ã¼ããç¶æ ã表ç¾ããä¸éã¯ã©ã¹ã§æ±æããå§ããã®ã¯é¿ãããã¨ãæã£ãã人ã®ç解ããããã¯æèã«å½±é¿ããã®ã§ãç¹å®ã®ç¶æ ãçµã¿åãããååã§ã¯è¡¨ç¾ã®éçãããããã«ãæãããã¨ã¯ãããä¸è¨ã®ããã«ç¶æ ãæ´çããããã¨ã¯å¤§åãªã®ã§ãæ´çããããã¨ãã¼ã ã§è°è«ããããããªãããã«æãã
Kotlin linterï½kgmyshin
ããããlinterãå°å ¥ãããªãå¿ èªã¨ãã£ã¦è¯ãçºè¡¨ã ã£ãã俺èªèº«ãAbemaã«ãã¦æåã«ãã£ãã®ãlinterã®å°å ¥ã ã£ãã®ã§ãã»ã¨ãã©ã®è©±ã¯ç解ãã¦ããããããããå ´ã§çºè¡¨ããæ©ä¼ãæã¦ãã¨ããããã£ã³ã¹ãã¤ããã¦ãã人ã®éããªã®ã ãªã¨æãããåç´ã«ã¢ã¦ããããã足ããªãã®ã ãããª...ãç¥è¦ã¯æºã¾ãã¤ã¤ããã®ã§ãã¿ããªãã¾ã ç解ãã¦ããªãã§ãããé¨åãæ·±æããã¦ããªãé¨åã詳ãã説æãããããªçºè¡¨ããã¦ããããã
webãããã¯ã¨ã³ãã®äººã¯é©ããããããªãããiOSãAndroidã®éçºã§ã¯ã¾ã linterãç©æ¥µçã«å°å ¥ãã¦ããã¨ããã¯å°ãªãã®ãç¾å®ã ã¨æãããããªãã®è¦æ¨¡ã®ãã¼ã ãããã°æ´ã£ã¦ããã¨æãããã¿ããªè¿·ããã«æåããå°å ¥ãã¦ããã¨ããä¾ã®æ¹ãå°ãªããããã¯lintãæ´åããããããã£ãã¨å®è£ ãã¦åããã»ããæ©ãã¨ããæå³ã§ãããããã«æãããã¾ããããå°ãªã人æ°ã§éçºããã¦ããç¾å ´ãå¤ãã®ã ãããªã¨ãæãããå°æ°ã§ãã£ã¦ããéããå£ä¼ããã°å°ããªããã¨ã¯ãããããããªããã¨ã¯ãããã¨ã³ã¸ãã¢ããè ããã«æãæãããã¯ãªãã®ã§ã¡ããã¨ããã¹ãã ããã¨ããã®ãæè«ã ãããã®ããã«è¶ ããªãã¨ãããªãéå£ã¯ã©ãã©ãæ¶ãã¦ããããªã¨ããã¹ã¿ã³ã¹ã ã
Kotlinã«é¢ãã¦ããã°ãGoogleãæä¾ããAndroidãµãã¼ãã©ã¤ãã©ãªã§ãæ¡ç¨ãã¦ããlinterãåå¨ããçºè¡¨ãä½åº¦ããã¦ãããktlintãããã ã俺ãããè¨ã£ã¦ããã®ã¯linterã¨formatterã®å½¹å²ã¯ãã¡ãã¨åãã¾ããããã¨ãããã¨ã ãå®éã«ã¯ããããè¿ãé¨åãåå¨ããã¨ã¯æãããæ¦å¿µãè¶ ããæ§è½ã¯ä¸è¦ãªã®ã§ãå½¹å²ã¯æ確ã«åãã¦ããã£ããååãå¤æ´ããã¹ãã ã¨ä¿ºã¯æã£ã¦ãããã¨ããæ°æã¡ããããã¼ã¶ã«ã«ããã®ãããã®ãããããªãã
ããããããã£ã¨ç¾å ´ã«æµ¸éããããã«æ¯æ´ãçºè¡¨ãè¡ãªã£ã¦ããããã
Kotlin ã³ã«ã¼ãã³ãç解ãããï½sys1yagi
ã³ã«ã¼ãã³ã«ã¤ãã¦ã¾ã ã¾ã ç解ã足ãã¦ããªãé¨åãå¤ãã£ããããããä¸æãã¦ãããç¥è³æã¨è¨ãã¹ããã®ã ã£ã...Qiitaã¨ãã§ä»ã®äººã®è¨äºãè¦ãããã¦ããããèªåã®ãããã¯ãã«å°å ¥ã§ããªãã¨æå³ããªãã®ã§ãç©æ¥µçã«ãã£ã¦ãããJavaã§ã¯ã©ã®ããã«å®è£ ãããã®ããKotlinã§ãããã©ã®ããã«å®ç¾ãã¦ããã®ãã¨ããæ°ã«ãªãé¨åãå ¨ã¦ä¸å¯§ã«ä¸ã¤ãã¤è§£èª¬ããã¦ããã®ã§ã絶対ã«èªã¾ãªããã°ãããªãè³æã ã£ããå³å»ãããã¯ãå°å ¥ãããããcoroutineã«ç½®ãæããã¡ãªããããªãã§ãããããã¡ãã¨èª¬æã§ããã¹ããªã®ã§ãããã¸ã§ã¯ãã«å°å ¥ããã«ã¯å¢ããããæ·±ãç解ãå¿ è¦ã ãªã¨æãããcoroutineèªä½ã¯å¤ãããããããã°ã©ãã³ã°ææ³ã¨è¨ããã®ã§ãæ¦å¿µçã«ã©ããããã®ãªã®ãã¨ãã説æããããã¨ãã¯ãç解ãé²ããJSãgoã®æèã§ã¯ã¨ã«ãããã¹ãã解æ¶ããã«ã¯ã¿ãããªå°è±¡ããæã£ã¦ããªãã£ããããªããã©ã®ããã«è§£æ±ºããã®ãã¨ããã®ãããã£ã¦ããã®ã§ãAndroidã§ã¯ãç¹ã«ããããåé¡ã解決ããããã¨ããã·ã¼ã³ãè¦ãã¦ããã°å°å ¥å¾ ã£ããªãã ã¨æãã
è°è«ããã¦ãã¦æ°ã«ãªãã®ã¯ãRxããã°ã©ãã³ã°ã§è§£æ±ºãããåé¡ã解決ããããã«coroutineãé©åãã©ããã¯ã¾ã ããããªãã¨ãããã¨ã ã£ããRxã®æ¦å¿µãææ³ã¯ç´ æ´ãããããcoroutineã§æ¬å½ã«åé¡ãªãç½®ãæããããããããããªããããããã®å®åå°å ¥ã§è¦ã¦ã¿ãªãã¨ããããªãé¨åãå¤ããã ãªã¨ãã·ã¹ãã ã§åãæ±ããã¼ã¿ã¨ã·ã¹ãã ã®ç¶æ ãç¬èªã®æ¦å¿µã§è¡¨ç¾ãã¦ããã¨ããç¹ã§ä¼¼ã¦ããããåºçºç¹ãéãã®ã§ãäºãã®ã«ãã¼ããããªãé åã¯ã§ã¦ãããã ãªã¨ããå°ä¸¦æã
ãã®è¾ºã®æè¡ãåå¼·ãã¦ããã¨ãã©ãã©ãæ°å¦ãã¢ã«ã´ãªãºã ã¨ãã¼ã¿æ§é ã«ã¤ãã¦ãã£ã¨CSã®ç解ããªãã¨ãª...ã¨åçããã°ããã§ããã
ãã¨ã¯LTä¼ãã¿ããã©ã3åãçããã¦ã»ã¨ãã©å¢ãããä¼ãããªãã£ã...2ä¸è¡ã®Javaãconvertããåæ°ããã...ã£ã¦æ°æã¡ãæ®ã£ãã
ããä½åº¦ãèãã¦ããããè³æãå³æ¥å ¬éãåç»ãé ä¿¡ã¨ãªãã¤ãã³ãã«è¶³ãéã¶æå³ã¯ãªããªã®ã ãããã¨ãããã¨ãããããªããªã£ã¦ããããããã¯ã¼ãã³ã°ãèªåã®çºè¡¨ãä½ãã®ååãã£ã³ã¹ãæ´ããªã©ã®ç®çãããã°è¯ãã¨ã¯æããå®éãä»åã¯åæãããããã¨è¨ã£ã¦ããã¤ãã³ãã®è©±ãèãã¦ãã¦ãããã«è¿ããã¨ããããã¨ãã¦ããmixiã®äººã®å°è©±ãèãããã®ã§ãããç¹ãã ãã§ãã¦ããã£ããä¼ç¤¾ã§ã¹ã«ã©ã·ããããããã¨ããããå¦çã¨äº¤æµããç®çããã£ãã®ã§åå ãã¦ããã£ããããã©ãåæ¥ã¯äººçã«ããã¦ãè²´éãªæéã§ããããã®1æ¥ãåå¼·ã®ããã ãã«ãªã¢ã«ã¿ã¤ã ã§æéãæ¶è²»ããããã¯ãéä¸ãã¦å®¶ã§æ å ±éããããæ¹ãå¹çãè¯ãã¨ã¯æã£ã¦ãããããã¤ããã人ããã©ã³ãã£ã³ã°ããããããããªããããã¾ãæéã使ããæ¹æ³ã§ä»ãåã£ã¦ããããã
çµãã£ãå¾ã¯ãã¤ãã®ã¡ã³ãã¼ã§board gameä¼ãããããããåææ¥ãæ¶ããã