Skip to content

Commit 58803a2

Browse files
author
DaeHoon Kim
committed
Unify code format with other ko-translation documents
1 parent 7f63b65 commit 58803a2

File tree

1 file changed

+21
-28
lines changed

1 file changed

+21
-28
lines changed

_ko/tour/tuples.md

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ previous-page: traits
1919

2020
두 개의 엘리먼트를 가진 튜플을 다음처럼 만들 수 있다.
2121

22-
```tut
23-
val ingredient = ("Sugar" , 25)
24-
```
22+
val ingredient = ("Sugar" , 25)
2523

2624
`String` 엘리먼트와 `Int` 엘리먼트로 이루어진 튜플이 생성된다.
2725

@@ -34,40 +32,35 @@ val ingredient = ("Sugar" , 25)
3432

3533
엘리먼트에 접근하는 한 가지 방법은 위치 정보를 이용하는 것이다. 각각의 엘리먼트들은 `_1`, `_2` 와 같은 명칭을 갖는다.
3634

37-
```tut
38-
println(ingredient._1) // Sugar
39-
println(ingredient._2) // 25
40-
```
35+
println(ingredient._1) // Sugar
36+
println(ingredient._2) // 25
37+
4138
## 튜플의 패턴 매칭
4239
[패턴 매칭](pattern-matching.html)을 이용하여 튜플을 분리할 수 있다.
4340

44-
```tut
45-
val (name, quantity) = ingredient
46-
println(name) // Sugar
47-
println(quantity) // 25
48-
```
41+
val (name, quantity) = ingredient
42+
println(name) // Sugar
43+
println(quantity) // 25
44+
4945
여기서 `name`의 추론 타입은 `String`이고, `quantity`의 추론 타입은 `Int`이다.
5046

5147
튜플 패턴 매칭의 또 다른 예는 다음과 같다.
5248

53-
```tut
54-
val planets =
55-
List(("Mercury", 57.9), ("Venus", 108.2), ("Earth", 149.6),
56-
("Mars", 227.9), ("Jupiter", 778.3))
57-
planets.foreach{
58-
case ("Earth", distance) =>
59-
println(s"Our planet is $distance million kilometers from the sun")
60-
case _ =>
61-
}
62-
```
49+
val planets =
50+
List(("Mercury", 57.9), ("Venus", 108.2), ("Earth", 149.6),
51+
("Mars", 227.9), ("Jupiter", 778.3))
52+
planets.foreach{
53+
case ("Earth", distance) =>
54+
println(s"Our planet is $distance million kilometers from the sun")
55+
case _ =>
56+
}
57+
6358
혹은, `for` 구문 안에서 다음처럼 사용할 수 있다.
6459

65-
```tut
66-
val numPairs = List((2, 5), (3, -7), (20, 56))
67-
for ((a, b) <- numPairs) {
68-
println(a * b)
69-
}
70-
```
60+
val numPairs = List((2, 5), (3, -7), (20, 56))
61+
for ((a, b) <- numPairs) {
62+
println(a * b)
63+
}
7164

7265
## 튜플과 케이스 클래스
7366
사용자들은 때때로 튜플과 [케이스 클래스](case-classes.html) 중 하나를 선택하는 것이 어려울 수 있다.

0 commit comments

Comments
 (0)