본문 바로가기

Data Engineering/Scala

(3)
vim-scala plugin vim-scala 플러그인이 계속 적용이 안돼서 검색하다보니 vim8로 업그레이드하면 된다는 글을 발견해서 해결. https://github.com/derekwyatt/vim-scala/issues/75 Can't get it work with Vundle · Issue #75 · derekwyatt/vim-scala Hi, This is probably some silly mistake that I am making, but I'm trying to install the plugin with Vundle: https://github.com/katcipis/my.vim/blob/master/vimrc#L73 And no magic happens :-(. I ... github.com
가변 파라미터(variable arguments)를 받는 메소드 스칼라로 가변적인 개수의 파라미터를 받는 메소드 만들기 & 사용하기 메소드를 선언할 때는 파라미터 타입 뒤에 * 문자를 붙인다. scala> def printAll(args: String*) = args.foreach(println) scala> printAll("hello") hello scala> printAll("hello", "world", "!") hello world ! 메소드를 사용할 때는 위의 예시처럼 하나하나 직접 넘겨도 되지만 보통 List, Array와 같은 Iterable 타입의 변수를 넘긴다. 하지만 그냥 Iterable을 넘기면 컴파일 에러가 난다. scala> val l = List("hello", "world") scala> printAll(l) :28: error: type..
Akka를 알아보자 Akka Actor 는 message passing을 통해 커뮤니케이션하는 entity다. - 당연하지만, 액터모델에서 message는 first-class citizen 이다. - Event-driven model: asynchronous 하게 메세지를 전달하기 때문에 스레드를 블락하지 않아도 된다. - Akka Actor 는 state와 behavior을 가진다. Akka Props을 사용해서 configuration을 명시한다. ActorSystem.actorOf (or ActorContext) 메소드에 Props[원하는_액터_클래스]를 전달해서 액터를 생성한다. Akka Actor에 Asynchronously 하게 메세지를 전달하는 방법으로는 tell과 ask가 있다. Tell Patern act..