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

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

9aba2147bb6e43333fcc42e2afc570f2?s=128

Shunsuke Tadokoro

April 18, 2019
Tweet

Transcript

  1. 3.
  2. 4.

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

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

    5SJQMF2VPUF "Hello triple quote!\nHello stripMargin!" """Hello triple quote! Hello stripMargin!"""

    """|Hello triple quote! |Hello stripMargin!""".stripMargin w վߦΛؚΉจࣈྻΛຒΊࠐΉʹ͸ɺΛ࢖͏ w ΠϯσϯτΛଗ͑Δʹ͸Πϯσϯτจࣈ c ͱTUSJQ.BSHJOΛ࢖͏
  4. 17.

    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 ͪΐͬͱͨ͠ςϯϓϨʔτΤϯδϯΈ͍ͨʹ࢖͏͜ͱ΋
  5. 22.

    ·ͱΊ w 4DBMBΛ࢓ࣄͰ࢖͓͏ʂ w ·ͣ͸ݸਓͷۀ຿Ͱ׬݁͢ΔൣғͰ΍ͬͯΈΑ͏ʂ w 4DBMB͸εέʔϥϒϧͳݴޠʂ w େ͖͍ϓϩμΫτ΋ɺখ͞ͳεΫϦϓτ΋͍͍ײ͡ʂ w

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

     5IBOLZPV Some(question) match { case Twitter => "@todokr" case

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