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 버전 기반)
525
14
스칼라 타입 시스템 I
14.1.2
타입 생성자
때로 매개변수화한 타입이라는 말 대신 타입 생성자
type
constructor
라는 용어를 사용하는 것을 볼
수 있다. 이는 어떤 클래스의 인스턴스를 만들어낼 때 인스턴스 생성자를 사용하는 것처럼,
체적인 타입을 만들어낼 때 매개변수화한 타입을 사용한다는 사실을 반영한다.
예를 들어
List
는 서로 다른 두 타입
List
[
String
]
List
[
Int
]
의 타입 생성자다. 사실 모든 클
래스를 타입 생성자라고 말할 수도 있다. 타입 매개변수가 없는 클래스는 실제로는 타입 매개변
수 인자가 하나도 없는 ‘매개변수화한 타입’이라고 생각할 수 있다.
14.1.3
타입 매개변수의 이름
타입 매개변수에 자신을 설명할 수 있는 이름을 부여하는 것을 고려해보라. 새로운 스칼라 개
발자들의 불만 중 하나는
List
.+:
과 같은 메서드의 스칼라독이나 구현에서 타입 매개변수에
A
B
같이 너무 간결한 이름이 사용된다는 것이다. 한편 다음과 같은 간단한 규칙을 따르면 이런
기호를 어떻게 해석해야 할지 쉽게 배울 수 있다.
1
. 컨테이너 원소 타입과 같이 아주 일반적인 타입 매개변수에 대해서는
A
,
B
,
T1
,
T2
와 같이
한두 자로 된 이름을 사용하라. 실제 원소 타입의 이름은 컨테이너와는 아무 관계가 없다
는 점에 주의하라.
List
는 문자열, 수, 다른 리스트 등 어떤 타입의 물건을 원소로 담더라
도 동일하게 작동한다. 이런 식의 분리는 ‘제네릭 프로그래밍’을 가능하게 해준다.
2
. 하부 컨테이너와 ...
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