Skip to Content
프로그래밍 스칼라: 실용적인 스칼라 활용법을 익히는 가장 확실한 실전 바이블 (2.11.x 버전 기반)
book

프로그래밍 스칼라: 실용적인 스칼라 활용법을 익히는 가장 확실한 실전 바이블 (2.11.x 버전 기반)

by 오현석, 딘 왐플러, 알렉스 페인
July 2016
Beginner to intermediate
776 pages
17h 26m
Korean
Hanbit Media, Inc.
Content preview from 프로그래밍 스칼라: 실용적인 스칼라 활용법을 익히는 가장 확실한 실전 바이블 (2.11.x 버전 기반)
236
2
기본기 다지기
없애버리는 것이다. 이런 식으로 타입은 있는데 인스턴스 정의는 없는 타입을 유령 타입
phantom
type
이라고 부른다. 이름이 멋지긴 하지만, 사실은 타입의 존재 여부만 관심의 대상이라는 의미
일 뿐이다. 유령 타입의 주 기능은 ‘표식’ 역할이다. 실제로는 그 타입의 인스턴스를 전혀 사용하
지 않는다.
지금 설명하려는 유령 타입의 사용법은 사실 암시와는 아무 관계가 없다. 하지만 우리가 해결하
려는 설계 문제를 논할 때는 딱 들어맞는다.
유령 타입은 특정 순서로 진행해야 하는 작업 흐름을 정의할 때 아주 유용하다. 예를 들어 단순
화한 급여 계산 프로그램을 생각해보자. 미국 세법에 따르면, 세금을 계산하기 전에 급여에서 보
험료와 특정 요건을 갖춘 저축(
401k
) 계정
1
에 대한 기여분을 공제해야 한다. 따라서 급여 계산
프로그램은 반드시 이런 ‘세전
pre
-
tax
’ 공제를 먼저 수행하고, 그 후 세금을 공제하고, 그 후 가능
한 세후 공제를 계산해서 지불 가능한 순 급여를 결정해야 한다.
다음은 한 가지 가능한 구현 방법을 보여준다.
//
src
/
main
/
scala
/
progscala2
/
implicits
/
phantom
-
types
.
scala
//
급여
계산을
위한
작업
흐름
package progscala
.
implicits
.
payroll
sealed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

스파크를 이용한 자연어 처리 : 대규모 텍스트를 다루는 가장 효율적인 딥러닝을 만나다

스파크를 이용한 자연어 처리 : 대규모 텍스트를 다루는 가장 효율적인 딥러닝을 만나다

이창현, 앨릭스 토머스

Publisher Resources

ISBN: 9788968482755