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

Scalaをはじめる β

Scalaをはじめる β

Tomohiko Himura

June 06, 2015
Tweet

More Decks by Tomohiko Himura

Other Decks in Programming

Transcript

  1. ͜Μͺ͍Δͯ͠ɻ $ cat HelloCompile.scala object HelloCompile { def main(args: Array[String])

    = println(“Hello, Z”) } $ scalac HelloCompile.scala $ scala HelloCompile Hello, Z
  2. NBJOΛ͓ʔ͹Β͍Ͳ object HelloExtendsAppOverrideMain extends App { println("Hello, Z") override def

    main(args: Array[String]) = println("start main") } ºೖ໳Ͱ͖ͳ͍ JOJU$PEFͷݺͼग़্͕͠ॻ͖͞ΕͯΔ
  3. EFMBZFE*OJUΛ͓ʔ͹Β͍Ͳ object HelloExtendsAppOverrideDelayedInit extends App { println("Hello, Z") override def

    delayedInit(body: => Unit) = println("start delayedInit") } ºೖ໳Ͱ͖ͳ͍ JOJU$PEFʹCPEZ͕௥Ճ͞Εͯͳ͍
  4. ࢀߟ object HelloExtendsAppOverrideBoth extends App { println("Hello, Z") override def

    delayedInit(body: => Unit) = println("start delayedInit") override def main(args: Array[String]) = println("start main") }
  5. ࢀߟ object HelloExtendsAppOverrideBoth extends App { println("Hello, Z") override def

    delayedInit(body: => Unit) = println("start delayedInit") override def main(args: Array[String]) = println("start main") } TUBSUEFMBZFE*OJU͕ઌ
  6. ͪΐͬͱζϧΛ͢Δ PCKFDU)FMMP#BE\ QSJOUMO )FMMP ;  EFGNBJO BSHT"SSBZ<4USJOH>  QSJOUMO

    TUBSUNBJO  ^ ʓೖ໳Ͱ͖Δ +BWBͷΫϥεॳظԽࢠͰ࣮ߦ͞ΕΔײ͡
  7. %FMBZFE*OJUΛ࢖ͬͯ PCKFDU)FMMP&YUFOET%FMBZFE*OJUFYUFOET%FMBZFE*OJU\ QSJOUMO )FMMP ;  PWFSSJEFEFGEFMBZFE*OJU CPEZ6OJU  QSJOUMO

    TUBSUEFMBZFE*OJU  EFGNBJO BSHT"SSBZ<4USJOH>  QSJOUMO TUBSUNBJO  ^ ºೖ໳Ͱ͖ͳ͍ CPEZΛར༻͍ͯ͠ͳ͍