Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
language:scala [2020/12/22 09:05] – [for] for-yield 설명 추가 ledyxlanguage:scala [2021/03/24 08:18] (current) – [Command Line] 프로젝트 생성/배포 내용 보강 ledyx
Line 13: Line 13:
 https://www.scala-lang.org/download/ https://www.scala-lang.org/download/
  
-SBT (Scala Build Tools)+=== SBT (Scala Build Tools) ===
 Scala의 Ant/Maven/Gradle와 비교될 수 있음. 직접으로 프로젝트 생성, 배포 관여. Scala의 Ant/Maven/Gradle와 비교될 수 있음. 직접으로 프로젝트 생성, 배포 관여.
 +
 +==== Create templates ====
 +
 +https://www.scala-sbt.org/1.x/docs/sbt-new-and-Templates.html
  
 <sxh shell> <sxh shell>
-# 생성 +sbt new scala/scala-seed.g8 
-sbt [Project Name]+</sxh>
  
 +
 +==== Fat Jar ====
 +
 +https://github.com/sbt/sbt-assembly
 +
 +<sxh shell>
 # Build (Fat Jar 생성) # Build (Fat Jar 생성)
 ## build.sbt에 ## build.sbt에
-## addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")+## addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.6")
 ## 추가 필요 ## 추가 필요
 ### 생성된 jar 위치 : target/scala-[version]/*.jar ### 생성된 jar 위치 : target/scala-[version]/*.jar
-sbt assemblyty+sbt assembly
  
 </sxh> </sxh>
  
  
-Scala Binaries (선택 사항)+ 
 +=== Scala Binaries (선택 사항) ===
   * REPL(scala), 단독 Compile(scalac)을 이용하기 위해 필요   * REPL(scala), 단독 Compile(scalac)을 이용하기 위해 필요
  
Line 985: Line 996:
 ==== Companion object ==== ==== Companion object ====
  
-어떤 class **이름**이 같은 object. 그 피대상인 class는 "Companion class"라고 한다. Companion object와  [[language:scala#'apply' Method|'apply' Method]]를 이용하여 Companion class의 <fc red>**__"Factory Pattern"__**</fc>을 적용할 때 사용.+어떤 class **이름**이 같은 object. 그 피대상인 class는 "Companion class"라고 한다. Companion object와  [[language:scala#'apply' Method|'apply' Method]]를 이용하여 Companion class의 [[design_pattern:factory_method_pattern|Factory Pattern]] 을 적용할 때 사용.
 이 때, object의 field들이 "private"으로 선언되어 있더라도 접근 가능. 이 때, object의 field들이 "private"으로 선언되어 있더라도 접근 가능.
  
Line 1321: Line 1332:
 = Abstract types = = Abstract types =
  
-<sxh scala ; highlight:[7,8,13,18]>+https://docs.scala-lang.org/tour/abstract-type-members.html 
 + 
 +<sxh scala ; highlight:[7,8,13,15,21,23]>
 import java.io._ import java.io._
 import scala.io.Source import scala.io.Source
Line 1328: Line 1341:
 // 위 소스를 응용한 예제 // 위 소스를 응용한 예제
 abstract class BulkReader { abstract class BulkReader {
-  type In        // 구체적인 타입을 지정하지 않음.+  type In // 구체적인 타입을 지정하지 않음.
   val source: In // 바로 위에서 지정한 Type인 "In"을 사용   val source: In // 바로 위에서 지정한 Type인 "In"을 사용
   def read: String   def read: String
 } }
  
-class StringBulkReader(val source: String) extends BulkReader { +class StringBulkReader 
-  type In = String+(val source: String)  // 추상 타입의 실질 타입 정의 
 +  extends BulkReader { 
 +  type In = String // 추상 타입 구체화 
   override def read: String = source   override def read: String = source
 } }
  
-class FileBulkReader(val source: File) extends BulkReader { +class FileBulkReader 
-  type In = File+(val source: File) // 추상 타입의 실질 타입 정의 
 +  extends BulkReader { 
 +  type In = File  // 추상 타입 구체화 
   override def read: String = {   override def read: String = {
     val source1 = Source.fromFile(source)     val source1 = Source.fromFile(source)
language/scala.1608627951.txt.gz · Last modified: 2021/02/07 03:15 (external edit)