Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scalaでつくる ちょっとしたCLIツール

Scalaでつくる ちょっとしたCLIツール

Shunsuke Tadokoro

April 18, 2019
Tweet

More Decks by Shunsuke Tadokoro

Other Decks in Technology

Transcript

  1. 4DBMB w +BWBͱͷ૬ޓӡ༻ੑ w γʔϜϨεͳݺͼग़͠ɺ+BWBඪ४ϥΠϒϥϦͷ࠶ར༻ w ؆ܿੑ w লུՄೳͳߏจɺܕਪ࿦ɺڧྗͳඪ४ϥΠϒϥϦ w

    ந৅౓ͷߴ͍ίʔυɺ৽੍͍͠ޚߏจΛఆٛͰ͖Δදݱྗ w 8IBUͷڧௐɺ)PXͷӅณ w ੩తܕ෇͚ w ݕূՄೳੑɺϦϑΝΫλͷ͠΍͢͞ɺυΩϡϝϯτੑ
  2. 5SJQMF2VPUF "Hello triple quote!\nHello stripMargin!" """Hello triple quote! Hello stripMargin!"""

    """|Hello triple quote! |Hello stripMargin!""".stripMargin w վߦΛؚΉจࣈྻΛຒΊࠐΉʹ͸ɺΛ࢖͏ w ΠϯσϯτΛଗ͑Δʹ͸Πϯσϯτจࣈ c ͱTUSJQ.BSHJOΛ࢖͏
  3. 4USJOH*OUFSQPMBUJPOͱ5SJQMF2VPUF val response = s"""HTTP/1.1 ${status.value} |Date: ${rfc1123Formatter.format(now)} |Server: SimpleScalaHttpServer

    |Content-Type: $contentType |Content-Length: ${body.length.toString} |Connection: Close | |""".stripMargin ͪΐͬͱͨ͠ςϯϓϨʔτΤϯδϯΈ͍ͨʹ࢖͏͜ͱ΋
  4. ·ͱΊ w 4DBMBΛ࢓ࣄͰ࢖͓͏ʂ w ·ͣ͸ݸਓͷۀ຿Ͱ׬݁͢ΔൣғͰ΍ͬͯΈΑ͏ʂ w 4DBMB͸εέʔϥϒϧͳݴޠʂ w େ͖͍ϓϩμΫτ΋ɺখ͞ͳεΫϦϓτ΋͍͍ײ͡ʂ w

    εΫϦϓςΟϯάʹศརͳػೳΛ஌͓ͬͯ͜͏ʂ w TDBMBJP4PVSDF w 4USJOH*OUFSQPMBUJPO w 5SJQMF2VPUF w ࣮ߦՄೳͳόΠφϦΛੜ੒͢Δ͜ͱ΋Ͱ͖ΔΑʂ w αΫαΫಈ͍ͯɺͦͷ··νʔϜʹڞ༗΋Ͱ͖Δʂ w མͱ݀͠΋͋Δ͔ΒؾΛ͚ͭΑ͏ʂ
  5.  5IBOLZPV Some(question) match { case Twitter => "@todokr" case

    GitHub => "@todokr" case Facebook => "shunsuke.tadokoro" case _ => invokeDynamic }