Skip to content

Translation tour ja #1387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 358 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
358 commits
Select commit Hold shift + click to select a range
9b97eb7
Update _ja/tour/regular-expression-patterns.md
tockri Apr 9, 2019
4553f67
Update _ja/tour/regular-expression-patterns.md
tockri Apr 9, 2019
217695f
Update _ja/tour/extractor-objects.md
tockri Apr 9, 2019
b647743
Update _ja/tour/extractor-objects.md
tockri Apr 9, 2019
de5d2f9
Update _ja/tour/extractor-objects.md
tockri Apr 9, 2019
5b8a4ad
Update _ja/tour/for-comprehensions.md
tockri Apr 9, 2019
cd14c4d
Update _ja/tour/for-comprehensions.md
tockri Apr 9, 2019
f8f1364
Update _ja/tour/for-comprehensions.md
tockri Apr 9, 2019
571f282
Update _ja/tour/for-comprehensions.md
tockri Apr 9, 2019
ba03ddd
Update _ja/tour/for-comprehensions.md
tockri Apr 9, 2019
dd36277
Update _ja/tour/for-comprehensions.md
tockri Apr 9, 2019
47db9ad
Update _ja/tour/generic-classes.md
tockri Apr 9, 2019
852c040
Update _ja/tour/generic-classes.md
tockri Apr 9, 2019
e869c94
Update _ja/tour/generic-classes.md
tockri Apr 9, 2019
2a659ea
Update _ja/tour/generic-classes.md
tockri Apr 9, 2019
590b9b9
Japanese translation of TOUR OF SCALA variances
take2webservice Apr 9, 2019
52a8cae
Japanese translation of TOUR OF SCALA upper-type-bounds
take2webservice Apr 9, 2019
cb055c0
Japanese translation of TOUR OF SCALA lower-type-bounds
take2webservice Apr 9, 2019
37999b2
Update _ja/tour/generic-classes.md
tockri Apr 9, 2019
03f59ed
Update _ja/tour/multiple-parameter-lists.md
take2webservice Apr 9, 2019
3271984
Japanese translation of TOUR OF SCALA inner-classes
take2webservice Apr 9, 2019
91ec5c7
Japanese translation of TOUR OF SCALA abstract-type-members
take2webservice Apr 9, 2019
2e5bcc7
Japanese translation of TOUR OF SCALA compound-types
take2webservice Apr 9, 2019
29b241d
Japanese translation of TOUR OF SCALA self-types
take2webservice Apr 9, 2019
771ef82
Japanese translation of TOUR OF SCALA implicit-parameters
take2webservice Apr 10, 2019
87acfc9
Update _ja/tour/variances.md
tockri Apr 11, 2019
df8fa67
Update _ja/tour/variances.md
tockri Apr 11, 2019
58f10f6
Update _ja/tour/variances.md
tockri Apr 11, 2019
629f34d
Update _ja/tour/variances.md
tockri Apr 11, 2019
7e930ab
Update _ja/tour/variances.md
tockri Apr 11, 2019
8e0db25
Update _ja/tour/variances.md
tockri Apr 11, 2019
2f87c85
Update _ja/tour/variances.md
tockri Apr 11, 2019
47b5645
Update _ja/tour/variances.md
tockri Apr 11, 2019
bef6518
Update _ja/tour/variances.md
tockri Apr 11, 2019
fd61bbf
Update _ja/tour/variances.md
tockri Apr 11, 2019
d82514f
Japanese translation of TOUR OF SCALA implicit-conversions
take2webservice Apr 11, 2019
f34c92f
Japanese translation of TOUR OF SCALA polymorphic-methods
take2webservice Apr 11, 2019
659a5b0
Japanese translation of TOUR OF SCALA type-inference
take2webservice Apr 11, 2019
9f9b78d
Japanese translation of TOUR OF SCALA operators
take2webservice Apr 11, 2019
5fe632f
Japanese translation of TOUR OF SCALA by-name-parameters
take2webservice Apr 11, 2019
b8a6c8d
Japanese translation of TOUR OF SCALA annotations
take2webservice Apr 11, 2019
d5f8c11
Japanese translation of TOUR OF SCALA default-parameter-values
take2webservice Apr 11, 2019
a139296
Japanese translation of TOUR OF SCALA named-arguments
take2webservice Apr 11, 2019
6ba235d
Japanese translation of TOUR OF SCALA packages-and-imports
take2webservice Apr 11, 2019
c3a4c3c
Japanese translation of TOUR OF SCALA package-objects
take2webservice Apr 12, 2019
c0ce5ae
adapt changes on aa641d51873480d9560e310afdcfb133fe1d4558
take2webservice Apr 12, 2019
996b6f1
remove Object extending App from example on japanese file
take2webservice Apr 12, 2019
41178f7
fix grammatical mistake: 'they are instances of' to 'each is an insta…
take2webservice Apr 12, 2019
2778b59
adapt latest changes on tuples document of tour of scala.
take2webservice Apr 12, 2019
a031f68
Update _ja/tour/upper-type-bounds.md
tockri Apr 14, 2019
a7f79cf
Update _ja/tour/upper-type-bounds.md
tockri Apr 14, 2019
a1e055f
Update _ja/tour/lower-type-bounds.md
tockri Apr 14, 2019
c6b838b
Update _ja/tour/lower-type-bounds.md
tockri Apr 14, 2019
9b0730e
Update _ja/tour/lower-type-bounds.md
tockri Apr 14, 2019
01ac2ca
Update _ja/tour/lower-type-bounds.md
tockri Apr 14, 2019
3dab31d
Update _ja/tour/lower-type-bounds.md
tockri Apr 14, 2019
cc3ec57
Update _ja/tour/lower-type-bounds.md
tockri Apr 14, 2019
f397bda
Update _ja/tour/lower-type-bounds.md
tockri Apr 14, 2019
7118dd4
Update _ja/tour/lower-type-bounds.md
tockri Apr 14, 2019
9830878
Update _ja/tour/abstract-type-members.md
tockri Apr 23, 2019
5dcd084
Update _ja/tour/abstract-type-members.md
tockri Apr 23, 2019
76a9e8e
Update _ja/tour/abstract-type-members.md
tockri Apr 23, 2019
3853e93
Update _ja/tour/abstract-type-members.md
tockri Apr 23, 2019
7389bea
Update _ja/tour/abstract-type-members.md
tockri Apr 23, 2019
9b47e8a
Update _ja/tour/abstract-type-members.md
tockri Apr 23, 2019
29cff3c
Update _ja/tour/abstract-type-members.md
tockri Apr 23, 2019
fca0364
Update _ja/tour/inner-classes.md
tockri Apr 23, 2019
d291349
Update _ja/tour/inner-classes.md
tockri Apr 23, 2019
2c9f72a
Update _ja/tour/inner-classes.md
tockri Apr 23, 2019
482d90e
Update _ja/tour/inner-classes.md
tockri Apr 23, 2019
dde02fc
Update _ja/tour/inner-classes.md
tockri Apr 23, 2019
23b2344
Update _ja/tour/inner-classes.md
tockri Apr 23, 2019
f8de5bb
Update _ja/tour/inner-classes.md
tockri Apr 23, 2019
141c7c6
Update _ja/tour/compound-types.md
tockri Apr 23, 2019
8c07f53
Update _ja/tour/compound-types.md
tockri Apr 23, 2019
4c0dc3b
Update _ja/tour/compound-types.md
tockri Apr 23, 2019
7d6a7ad
Update _ja/tour/compound-types.md
tockri Apr 23, 2019
3d29ea4
Update _ja/tour/compound-types.md
tockri Apr 23, 2019
6481baf
Update _ja/tour/compound-types.md
tockri Apr 23, 2019
4d97063
Update _ja/tour/compound-types.md
tockri Apr 23, 2019
77a722c
Update _ja/tour/self-types.md
tockri Apr 23, 2019
e1cab5e
Update _ja/tour/self-types.md
tockri Apr 23, 2019
9da0361
Update _ja/tour/self-types.md
tockri Apr 23, 2019
42c1e0d
Update _ja/tour/self-types.md
tockri Apr 23, 2019
4cdeb57
Update _ja/tour/self-types.md
tockri Apr 23, 2019
1c2374e
Update _ja/tour/implicit-parameters.md
tockri Apr 23, 2019
f818da0
Update _ja/tour/implicit-parameters.md
tockri Apr 23, 2019
84ab042
Update _ja/tour/implicit-parameters.md
tockri Apr 23, 2019
57266f2
Update _ja/tour/implicit-parameters.md
tockri Apr 23, 2019
24e4a6c
Update _ja/tour/implicit-parameters.md
tockri Apr 23, 2019
fc8167f
Update _ja/tour/implicit-parameters.md
tockri Apr 23, 2019
8b8354f
Update _ja/tour/implicit-parameters.md
tockri Apr 23, 2019
9532f24
Update _ja/tour/implicit-parameters.md
tockri Apr 23, 2019
bf07773
Update _ja/tour/implicit-parameters.md
tockri Apr 23, 2019
0af24c7
Update _ja/tour/implicit-parameters.md
tockri Apr 23, 2019
8b1152e
Update _ja/tour/implicit-conversions.md
tockri Apr 23, 2019
ae17f5e
Update _ja/tour/implicit-conversions.md
tockri Apr 23, 2019
731a43e
Update _ja/tour/implicit-conversions.md
tockri Apr 23, 2019
7aececd
Update _ja/tour/implicit-conversions.md
tockri Apr 23, 2019
15a7249
Update _ja/tour/implicit-conversions.md
tockri Apr 23, 2019
773badc
Update _ja/tour/implicit-conversions.md
tockri Apr 23, 2019
44b1139
Update _ja/tour/implicit-conversions.md
tockri Apr 23, 2019
6784f92
Update _ja/tour/implicit-conversions.md
tockri Apr 23, 2019
af26494
Update _ja/tour/implicit-conversions.md
tockri Apr 23, 2019
0059b55
Update _ja/tour/implicit-conversions.md
tockri Apr 23, 2019
5ffd5e2
Update _ja/tour/polymorphic-methods.md
take2webservice Apr 23, 2019
21b6e15
Update _ja/tour/polymorphic-methods.md
tockri Apr 23, 2019
85627c1
Update _ja/tour/polymorphic-methods.md
tockri Apr 23, 2019
7a2320c
Update _ja/tour/polymorphic-methods.md
tockri Apr 23, 2019
3877971
Update _ja/tour/polymorphic-methods.md
tockri Apr 23, 2019
c3db42c
Update _ja/tour/polymorphic-methods.md
tockri Apr 23, 2019
b0e045d
Update _ja/tour/polymorphic-methods.md
tockri Apr 23, 2019
943b878
Update _ja/tour/type-inference.md
tockri Apr 28, 2019
b658b9b
Update _ja/tour/type-inference.md
tockri Apr 28, 2019
9c35586
Update _ja/tour/type-inference.md
tockri Apr 28, 2019
a8034fa
Update _ja/tour/type-inference.md
tockri Apr 28, 2019
ab90954
Update _ja/tour/type-inference.md
tockri Apr 28, 2019
44b3d8e
Update _ja/tour/type-inference.md
tockri Apr 28, 2019
37d2bb3
Update _ja/tour/type-inference.md
tockri Apr 28, 2019
a5f5b53
Update _ja/tour/operators.md
tockri Apr 28, 2019
4bcd828
Update _ja/tour/operators.md
tockri Apr 28, 2019
fb29d19
Update _ja/tour/operators.md
tockri Apr 28, 2019
a496eb2
Update _ja/tour/operators.md
tockri Apr 28, 2019
41417f4
Update _ja/tour/operators.md
tockri Apr 28, 2019
09a0c32
Update _ja/tour/operators.md
tockri Apr 28, 2019
b8c296b
Update _ja/tour/operators.md
tockri Apr 28, 2019
a2041c4
Update _ja/tour/operators.md
tockri Apr 28, 2019
58036ba
Update _ja/tour/by-name-parameters.md
tockri Apr 28, 2019
3936af8
Update _ja/tour/by-name-parameters.md
tockri Apr 28, 2019
9c0e642
Update _ja/tour/by-name-parameters.md
tockri Apr 28, 2019
720fcbc
Update _ja/tour/by-name-parameters.md
tockri Apr 28, 2019
5fd0923
Update _ja/tour/by-name-parameters.md
tockri Apr 28, 2019
e17b616
Update _ja/tour/by-name-parameters.md
tockri Apr 28, 2019
77df071
Update _ja/tour/annotations.md
tockri Apr 28, 2019
bfb32cd
Update _ja/tour/annotations.md
tockri Apr 28, 2019
1c90bd9
Update _ja/tour/annotations.md
tockri Apr 28, 2019
7d371b1
Update _ja/tour/annotations.md
tockri Apr 28, 2019
5c8bb1b
Update _ja/tour/annotations.md
tockri Apr 28, 2019
5b95d3b
Update _ja/tour/annotations.md
tockri Apr 28, 2019
c1471cd
Update _ja/tour/annotations.md
tockri Apr 28, 2019
5a970f7
Update _ja/tour/annotations.md
tockri Apr 28, 2019
4ed05a7
Update _ja/tour/annotations.md
tockri Apr 28, 2019
2519b5f
Update _ja/tour/default-parameter-values.md
tockri Apr 29, 2019
a1b79ef
Update _ja/tour/default-parameter-values.md
tockri Apr 29, 2019
7b91956
Update _ja/tour/default-parameter-values.md
tockri Apr 29, 2019
57e12ed
Update _ja/tour/default-parameter-values.md
tockri Apr 29, 2019
a5db342
Update _ja/tour/named-arguments.md
tockri Apr 29, 2019
f0c94ef
Update _ja/tour/named-arguments.md
tockri Apr 29, 2019
b44d174
Update _ja/tour/named-arguments.md
tockri Apr 29, 2019
57cc250
Update _ja/tour/packages-and-imports.md
tockri Apr 29, 2019
ee97eea
Update _ja/tour/packages-and-imports.md
tockri Apr 29, 2019
a97b1cc
Update _ja/tour/packages-and-imports.md
tockri Apr 29, 2019
8401486
Update _ja/tour/packages-and-imports.md
tockri Apr 29, 2019
2b3774f
Update _ja/tour/packages-and-imports.md
tockri Apr 29, 2019
e87d43a
Update _ja/tour/package-objects.md
tockri May 4, 2019
76f2686
Update _ja/tour/package-objects.md
tockri May 4, 2019
786f862
Update _ja/tour/package-objects.md
tockri May 4, 2019
0826e33
Update _ja/tour/package-objects.md
tockri May 4, 2019
4aaf146
Update _ja/tour/package-objects.md
tockri May 4, 2019
203f6f6
Update _ja/tour/package-objects.md
tockri May 4, 2019
0eb3e3a
Update _ja/tour/tuples.md
tockri May 4, 2019
640559b
Update _ja/tour/tuples.md
tockri May 4, 2019
0c57048
Update _ja/tour/tuples.md
tockri May 4, 2019
45b2778
Update _ja/tour/tuples.md
tockri May 4, 2019
1aaaaef
Update _ja/tour/tuples.md
tockri May 4, 2019
aa3ee0d
Update _ja/tour/tuples.md
tockri May 4, 2019
7259020
Update _ja/tour/tuples.md
tockri May 4, 2019
32261f0
Update _ja/tour/tuples.md
tockri May 4, 2019
369dbde
訳が不自然なところを訂正
tockri May 5, 2019
552b87f
よくよく
tockri May 5, 2019
da4d603
冗長すぎる部分とコンビニ敬語の指摘
tockri May 5, 2019
09e4e2a
再確認
tockri May 5, 2019
fdcbbdc
再確認
tockri May 6, 2019
624e3f0
再確認
tockri May 6, 2019
0c61586
再確認
tockri May 6, 2019
72dae7c
再確認
tockri May 7, 2019
76fb205
再確認
tockri May 7, 2019
127a0f6
再確認
tockri May 9, 2019
6543402
再確認
tockri May 9, 2019
ea2aab7
リンク記法の誤り訂正
tockri May 18, 2019
20fd0df
不変→非変に変更
tockri May 18, 2019
470d3dc
訳し漏れとか、意味の通じにくいところとか再確認
tockri May 18, 2019
b3f69e7
再確認
tockri May 20, 2019
ed567e3
再確認
tockri May 20, 2019
9bfa23f
再確認
tockri May 20, 2019
26602a0
再確認
tockri May 24, 2019
b5aa7ee
再確認
tockri May 24, 2019
2fe7b5f
自己型→自分型
tockri May 24, 2019
2584008
adapt changes in 9afd159f5556ad9a772e8a264e000d30d910c168
take2webservice May 29, 2019
44fa183
再確認
take2webservice May 29, 2019
3cd5f38
てにをは修正
take2webservice May 31, 2019
83d2635
不変=>非変, ジェネリックタイプ=>ジェネリック型
take2webservice May 31, 2019
0495a48
別がいっぱいあって気持ち悪いので、他に変更
take2webservice Jun 2, 2019
9b6981a
微修正
take2webservice Jun 2, 2019
4e15e26
language属性追加、不要な「です」削除
take2webservice Jun 2, 2019
5ce4947
ワード漏れ
take2webservice Jun 2, 2019
6abc981
オペレータ=>演算子
take2webservice Jun 2, 2019
0f9a11c
add language:ja
take2webservice Jun 2, 2019
1e30446
微修正
take2webservice Jun 2, 2019
b58bf06
add language: ja
take2webservice Jun 2, 2019
fb364ff
再確認
tockri Jun 19, 2019
aaf656f
再確認
tockri Jun 19, 2019
1cc2151
再確認
tockri Jun 20, 2019
0942e77
Update _ja/tour/annotations.md
take2webservice Jun 21, 2019
05303f6
原文に合わせ不要な改行を削除
take2webservice Jun 21, 2019
637b23e
remove untranslated file
take2webservice Jun 21, 2019
a36eaf4
enumeratorsは複数の値を生成しうる
take2webservice Jun 22, 2019
ae81508
Update _ja/tour/for-comprehensions.md
take2webservice Jun 22, 2019
9ae2596
Update _ja/tour/higher-order-functions.md
take2webservice Jun 22, 2019
53484c7
Update _ja/tour/higher-order-functions.md
take2webservice Jun 22, 2019
1f060b9
Update _ja/tour/implicit-conversions.md
take2webservice Jun 24, 2019
3a838fd
Update _ja/tour/implicit-conversions.md
take2webservice Jun 24, 2019
f601b5f
Update _ja/tour/implicit-conversions.md
take2webservice Jun 24, 2019
779d899
Update _ja/tour/mixin-class-composition.md
take2webservice Jun 24, 2019
2f5b43d
Update _ja/tour/multiple-parameter-lists.md
take2webservice Jun 24, 2019
83d164c
Update _ja/tour/multiple-parameter-lists.md
take2webservice Jun 24, 2019
aa23d5d
Update _ja/tour/nested-functions.md
take2webservice Jun 24, 2019
04a2a94
Update _ja/tour/package-objects.md
take2webservice Jun 24, 2019
c6f7ce2
Update _ja/tour/package-objects.md
take2webservice Jun 24, 2019
9fa868b
Update _ja/tour/package-objects.md
take2webservice Jun 24, 2019
c13f87c
Update _ja/tour/pattern-matching.md
take2webservice Jun 24, 2019
c063377
Update _ja/tour/pattern-matching.md
take2webservice Jun 24, 2019
806b839
Update _ja/tour/pattern-matching.md
take2webservice Jun 24, 2019
cec1bf1
Update _ja/tour/pattern-matching.md
take2webservice Jun 24, 2019
c537688
Update _ja/tour/pattern-matching.md
take2webservice Jun 24, 2019
1e87554
Update _ja/tour/pattern-matching.md
take2webservice Jun 24, 2019
34925ab
Update _ja/tour/polymorphic-methods.md
take2webservice Jun 24, 2019
f89ee26
Update _ja/tour/polymorphic-methods.md
take2webservice Jun 24, 2019
e23dad7
Update _ja/tour/regular-expression-patterns.md
take2webservice Jun 24, 2019
ad6353a
Update _ja/tour/singleton-objects.md
take2webservice Jun 24, 2019
c62cb06
Update _ja/tour/tour-of-scala.md
take2webservice Jun 24, 2019
4daa0b5
Update _ja/tour/tour-of-scala.md
take2webservice Jun 24, 2019
d111112
Update _ja/tour/tour-of-scala.md
take2webservice Jun 24, 2019
69f6ea0
Update _ja/tour/traits.md
take2webservice Jun 24, 2019
45b232f
Update _ja/tour/unified-types.md
take2webservice Jun 24, 2019
5480bf7
Update _ja/tour/tour-of-scala.md
take2webservice Jun 24, 2019
b9de5c1
Update _ja/tour/tour-of-scala.md
take2webservice Jun 24, 2019
a9f8baf
Update _ja/tour/tour-of-scala.md
take2webservice Jun 24, 2019
53b104d
Update _ja/tour/singleton-objects.md
take2webservice Jun 24, 2019
9fe0f2a
add untranslated file to compile
take2webservice Jun 24, 2019
c2010ff
Update _ja/tour/tour-of-scala.md
take2webservice Jun 25, 2019
5d2dfc6
Update _ja/tour/basics.md
take2webservice Jun 25, 2019
e2fccf1
Update _ja/tour/basics.md
take2webservice Jun 25, 2019
dfeb7ce
Update _ja/tour/basics.md
take2webservice Jun 25, 2019
d13c4d1
Update _ja/tour/basics.md
take2webservice Jun 25, 2019
10bbc1a
Update _ja/tour/basics.md
take2webservice Jun 25, 2019
e6e9a72
Update _ja/tour/basics.md
take2webservice Jun 25, 2019
584c2e6
Update _ja/tour/classes.md
take2webservice Jun 25, 2019
df31554
Update _ja/tour/classes.md
take2webservice Jun 25, 2019
11b26fb
Update _ja/tour/higher-order-functions.md
take2webservice Jun 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _data/translations.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
tour:
languages: [ba, es, ko, pt-br, pl, zh-cn, th, ru]
languages: [ba, es, ko, pt-br, pl, zh-cn, th, ru, ja]
79 changes: 79 additions & 0 deletions _ja/tour/abstract-type-members.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
layout: tour
title: 抽象型メンバー
language: ja

discourse: true

partof: scala-tour
num: 23
next-page: compound-types
previous-page: inner-classes
topics: abstract type members
prerequisite-knowledge: variance, upper-type-bound

redirect_from: "/tutorials/tour/abstract-types.html"
redirect_from: "/tour/abstract-types.html"
---

トレイトや抽象クラスのような抽象型は抽象型メンバーを持つことができます。
これは具体的な実装で実際の型を定義するという意味です。
こちらが例です。

```tut
trait Buffer {
type T
val element: T
}
```
こちらでは、抽象型`type T`を定義しています。それは`element`の型を記述するために使われます。このトレイトを抽象クラスで継承し、より具体的にするために上限型境界を`T`に追加することができます。

```tut
abstract class SeqBuffer extends Buffer {
type U
type T <: Seq[U]
def length = element.length
}
```
`T`の上限型境界の定義に出てきた、更に別の抽象型`U`の使い方に気をつけてください。この`class SeqBuffer`はこのバッファーの中にシーケンスのみを保持することができます。それは型`T`は新しい抽象型`U`を使った`Seq[U]`のサブタイプであると記述しているからです。

抽象型メンバーを持つトレイトと[クラス](classes.html)は無名クラスのインスタンス化と組み合わせてよく使われます。
これを説明するために、今から整数のリストを参照するシーケンスバッファーを扱うプログラムを見てみます。

```tut
abstract class IntSeqBuffer extends SeqBuffer {
type U = Int
}


def newIntSeqBuf(elem1: Int, elem2: Int): IntSeqBuffer =
new IntSeqBuffer {
type T = List[U]
val element = List(elem1, elem2)
}
val buf = newIntSeqBuf(7, 8)
println("length = " + buf.length)
println("content = " + buf.element)
```
ここで、ファクトリー`newIntSeqBuf`は抽象型`T`を具体的な型`List[Int]`に設定するために、`IntSeqBuf`(つまり`new IntSeqBuffer`)を無名クラスで実装します。

抽象型メンバーをクラスの型パラメータに変えることも、その逆も可能です。以下は上記コードの型パラメータのみを使うバージョンです。

```tut
abstract class Buffer[+T] {
val element: T
}
abstract class SeqBuffer[U, +T <: Seq[U]] extends Buffer[T] {
def length = element.length
}

def newIntSeqBuf(e1: Int, e2: Int): SeqBuffer[Int, Seq[Int]] =
new SeqBuffer[Int, List[Int]] {
val element = List(e1, e2)
}

val buf = newIntSeqBuf(7, 8)
println("length = " + buf.length)
println("content = " + buf.element)
```
ここでは(`+T <: Seq[U]`)をメソッド`newIntSeqBuf`から戻されるオブジェクトの具体的なシーケンス実装の型を隠すために [変位指定アノテーション](variances.html)を使わなければなりません。さらに、抽象型メンバをパラメータで置換することができないケースがあります。
130 changes: 130 additions & 0 deletions _ja/tour/annotations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
layout: tour
title: アノテーション
language: ja

discourse: true

partof: scala-tour

num: 32
next-page: default-parameter-values
previous-page: by-name-parameters

redirect_from: "/tutorials/tour/annotations.html"
---

アノテーションはメタ情報と定義を関連づけます。例えば、メソッドの前のアノテーション`@deprecated`はメソッドが使われたらコンパイラに警告を出力させます。
```
object DeprecationDemo extends App {
@deprecated("deprecation message", "release # which deprecates method")
def hello = "hola"

hello
}
```
これはコンパイルされますが、コンパイラは警告"there was one deprecation warning"を出力します。

アノテーション句はそれに続く最初の定義か宣言に適用されます。定義と宣言の前には1つ以上のアノテーション句を置くことができます。これらの句の順番は重要ではありません。


## エンコーディングの正確性を保証するアノテーション
条件が一致しない場合にコンパイルを失敗させるアノテーションもあります。例えば、アノテーション`@tailrec`はメソッドが[末尾再帰](https://en.wikipedia.org/wiki/Tail_call)であると保証します。末尾再帰ではメモリ使用量が一定になります。こちらは階乗を計算するメソッドの中での使われ方です。
```tut
import scala.annotation.tailrec

def factorial(x: Int): Int = {

@tailrec
def factorialHelper(x: Int, accumulator: Int): Int = {
if (x == 1) accumulator else factorialHelper(x - 1, accumulator * x)
}
factorialHelper(x, 1)
}
```
`factorialHelper`メソッドは`@tailrec`を持ちます。`@tailrec`はメソッドが実際に末尾再帰であると保証します。もし`factorialHelper`の実装を以下のように変更すれば、失敗し
```
import scala.annotation.tailrec

def factorial(x: Int): Int = {
@tailrec
def factorialHelper(x: Int): Int = {
if (x == 1) 1 else x * factorialHelper(x - 1)
}
factorialHelper(x)
}
```
"Recursive call not in tail position"というメッセージを受け取ります。


## コード生成に影響するアノテーション
`@inline`のようなアノテーションは生成されたコードに影響します(つまり、アノテーションを使わなかった場合とでjarファイルのバイト数が異なる場合があります)。インライン化とは、メソッドを呼び出している箇所にメソッド本体のコードを挿入することを意味します。結果のバイトコードはより長くなりますが、上手くいけば実行が早くなります。アノテーション`@inline`を使ってもメソッドのインライン化が保証されるわけではありません。しかし、生成されたコードのサイズに関するヒューリスティックスが満たされた場合に限りコンパイラにインライン化をさせます。

### Javaのアノテーション ###
Javaと相互運用するScalaのコードを書いている時、記述するアノテーション構文は少し違います。

**注:** Javaアノテーションを使う場合、`-target:jvm-1.8`オプションを使ってください。

Javaには[アノテーション](https://docs.oracle.com/javase/tutorial/java/annotations/)の形をしたユーザー定義メタデータがあります。Javaのアノテーションの特徴は、要素の初期化のために名前と値のペアを指定する必要があることです。例えば、クラスのソースを追いかけるためのアノテーションが必要なとき、以下のように定義するかもしれません。

```
@interface Source {
public String URL();
public String mail();
}
```

そして、それは以下のように適用されます。

```
@Source(URL = "http://coders.com/",
mail = "support@coders.com")
public class MyClass extends TheirClass ...
```

Scalaでのアノテーションの適用はコンストラクタの呼び出しと似ています。Javaのアノテーションをインスタンス化するためには名前付き引数を使う必要があります。

```
@Source(URL = "http://coders.com/",
mail = "support@coders.com")
class MyScalaClass ...
```

アノテーションが(デフォルト値を除き)要素を1つだけ含む場合、この構文はかなり退屈です。そのため慣例により、名前が`value`と指定されていれば、コンストラクタのような構文でJavaに適用できます。

```
@interface SourceURL {
public String value();
public String mail() default "";
}
```

そして以下のように適用します。

```
@SourceURL("http://coders.com/")
public class MyClass extends TheirClass ...
```

この場合、Scalaでも同じことができます。

```
@SourceURL("http://coders.com/")
class MyScalaClass ...
```

`mail`要素はデフォルト値つきで定義されているので、明示的に値を指定する必要がありません。しかしながら、もし値を指定する必要がある場合、Javaでは2つのスタイルを混ぜて組み合わせることはできません。

```
@SourceURL(value = "http://coders.com/",
mail = "support@coders.com")
public class MyClass extends TheirClass ...
```

Scalaはこの点においてより柔軟です。

```
@SourceURL("http://coders.com/",
mail = "support@coders.com")
class MyScalaClass ...
```
62 changes: 62 additions & 0 deletions _ja/tour/automatic-closures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
layout: tour
title: Automatic Type-Dependent Closure Construction
language: ja

discourse: true

partof: scala-tour
---

Scala allows parameterless function names as parameters of methods. When such a method is called, the actual parameters for parameterless function names are not evaluated and a nullary function is passed instead which encapsulates the computation of the corresponding parameter (so-called *call-by-name* evaluation).

The following code demonstrates this mechanism:

object TargetTest1 extends Application {
def whileLoop(cond: => Boolean)(body: => Unit): Unit =
if (cond) {
body
whileLoop(cond)(body)
}
var i = 10
whileLoop (i > 0) {
println(i)
i -= 1
}
}

The function whileLoop takes two parameters `cond` and `body`. When the function is applied, the actual parameters do not get evaluated. But whenever the formal parameters are used in the body of `whileLoop`, the implicitly created nullary functions will be evaluated instead. Thus, our method `whileLoop` implements a Java-like while-loop with a recursive implementation scheme.

We can combine the use of [infix/postfix operators](operators.html) with this mechanism to create more complex statements (with a nice syntax).

Here is the implementation of a loop-unless statement:

object TargetTest2 extends Application {
def loop(body: => Unit): LoopUnlessCond =
new LoopUnlessCond(body)
protected class LoopUnlessCond(body: => Unit) {
def unless(cond: => Boolean) {
body
if (!cond) unless(cond)
}
}
var i = 10
loop {
println("i = " + i)
i -= 1
} unless (i == 0)
}
The `loop` function just accepts a body of a loop and returns an instance of class `LoopUnlessCond` (which encapsulates this body object). Note that the body didn't get evaluated yet. Class `LoopUnlessCond` has a method `unless` which we can use as a *infix operator*. This way, we achieve a quite natural syntax for our new loop: `loop { < stats > } unless ( < cond > )`.

Here's the output when `TargetTest2` gets executed:

i = 10
i = 9
i = 8
i = 7
i = 6
i = 5
i = 4
i = 3
i = 2
i = 1
Loading