Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1cf772a
[Macro]マクロのチャプターの追加
stzn Jun 3, 2023
cda02ab
Merge remote-tracking branch 'origin/master' into macro
stzn Jun 4, 2023
33ff838
マクロ対応追加
stzn Jun 4, 2023
0a82a26
[宣言]原文の形式に合わせるように変更
stzn Jun 4, 2023
5f41040
[式]原文の形式に合わせるように変更
stzn Jun 4, 2023
0d0aed7
[字句構造]原文の形式に合わせるように変更
stzn Jun 4, 2023
a9da3c5
[文]原文の形式に合わせるように変更
stzn Jun 4, 2023
ded6fca
[文法のまとめ, SUMMARY]マクロ対応の追加
stzn Jun 4, 2023
5764573
[README]バージョン履歴更新
stzn Jun 4, 2023
b798a19
[パターン]画像からコードへ変更
stzn Jun 4, 2023
891ff8a
[制御フロー]画像からコードへ変更
stzn Jun 4, 2023
d774717
[コレクション型]画像からコードへ変更
stzn Jun 4, 2023
58e7e40
[クロージャ]画像からコードへ変更
stzn Jun 4, 2023
fa1031c
[初期化]画像からコードへ変更
stzn Jun 4, 2023
a17c980
[エラーハンドリング]画像からコードへ変更
stzn Jun 4, 2023
5defd77
[コレクション型、属性、ジェネリックパラメータと引数]画像からコードへ変更
stzn Jun 4, 2023
806d7c3
不要な画像の削除
stzn Jun 4, 2023
e8ed1e9
Merge remote-tracking branch 'origin/master' into macro
stzn Jun 5, 2023
f0e831c
ドキュメント改訂履歴の更新
stzn Jun 5, 2023
b23fa0f
[Macros]原文のリンクを追加
stzn Jun 6, 2023
3cebd7b
[改訂履歴]Swift5.9更新
stzn Jun 6, 2023
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

## バージョン履歴

- 2022/8/1 Swift5.7(beta)
- 2023/6/4 Swift5.9(beta)
- 2022/9/12 Swift5.7
- 2022/3/16 Swift5.6
- 2021/9/21 Swift5.5

Expand Down
1 change: 1 addition & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [オプショナルチェーン\(Optional Chaining\)](language-guide/optional-chaining.md)
* [エラー処理\(Error Handling\)](language-guide/error-handling.md)
* [同時並行処理\(Concurrency\)](language-guide/concurrency.md)
* [マクロ\(Macros\)](language-guide/macros.md)
* [型キャスト\(Type Casting\)](language-guide/type-casting.md)
* [ネスト型\(Nested Types\)](language-guide/nested-types.md)
* [拡張\(Extensions\)](language-guide/extensions.md)
Expand Down
12 changes: 11 additions & 1 deletion Style.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ TSPL は 3 つの主なパートに加えて、補完的な機能を提供する

# 用語とルール

## 属性名

ガイドでは、属性名の前に `@` を書きます。
リファレンスでは、省略します。

## back deploy

2 つの単語でつづり、1 単語にしたり、ハイフンを付けない
2 つの単語でつづり、1 単語にしたり、ハイフンを付けません

## コンパイラ

Expand All @@ -52,6 +57,11 @@ TSPL は 3 つの主なパートに加えて、補完的な機能を提供する

"member-wise"のようにハイフンをつけないでください。

## マクロ名

ガイドでは付属マクロ(attached macros)を指す場合は名前の前に `@` を、自立式マクロ(freestanding macros)を指す場合は名前の前に `#` を記述します。
リファレンスでは、省略します。

## メソッド

「関数」の項目を見てください。
Expand Down
Binary file removed assets/04_dictionarycreating.png
Binary file not shown.
Binary file removed assets/05_availabilitycondition.png
Binary file not shown.
Binary file removed assets/05_lebeledstatements.png
Binary file not shown.
Binary file removed assets/05_repeatwhile.png
Binary file not shown.
Binary file removed assets/05_switchform.png
Binary file not shown.
Binary file removed assets/05_whileform.png
Binary file not shown.
Binary file removed assets/07_closureexpressionsyntax.png
Binary file not shown.
Binary file removed assets/14_convenienceInitializer.png
Binary file not shown.
Binary file removed assets/14_designatedInitializer.png
Binary file not shown.
Binary file removed assets/17_errorHandling.png
Binary file not shown.
Binary file removed assets/actor_declaration.png
Binary file not shown.
Binary file removed assets/array_expression.png
Binary file not shown.
Binary file removed assets/array_type.png
Binary file not shown.
Binary file removed assets/arrayliteral_2x.png
Binary file not shown.
Binary file removed assets/assignment_operator.png
Binary file not shown.
Binary file removed assets/asynchronous_functions_and_methods.png
Binary file not shown.
Binary file removed assets/attributes.png
Binary file not shown.
Binary file removed assets/available.png
Binary file not shown.
Binary file removed assets/await_operator.png
Binary file not shown.
Binary file removed assets/await_throw_closure_expression.png
Binary file not shown.
Binary file removed assets/binary_expression.png
Binary file not shown.
Binary file removed assets/break_statement.png
Binary file not shown.
Binary file removed assets/class_declaration.png
Binary file not shown.
Binary file removed assets/closure_expression.png
Binary file not shown.
Binary file removed assets/code_blocks.png
Binary file not shown.
Diff not rendered.
Binary file removed assets/constant_declaration.png
Diff not rendered.
Binary file removed assets/continue_statement.png
Diff not rendered.
Binary file removed assets/defer_statement.png
Diff not rendered.
Binary file removed assets/deinitializer_declaration.png
Diff not rendered.
Binary file removed assets/deprecated.png
Diff not rendered.
Binary file removed assets/dictionary_expression.png
Diff not rendered.
Binary file removed assets/dictionary_type.png
Diff not rendered.
Binary file removed assets/do_catch_statement.png
Diff not rendered.
Diff not rendered.
Binary file removed assets/enumerations_with_cases_of_any_type.png
Diff not rendered.
Binary file removed assets/error_warning_compiler_statement.png
Diff not rendered.
Binary file removed assets/explicit_member_expression.png
Diff not rendered.
Binary file removed assets/extension_declaration.png
Diff not rendered.
Binary file removed assets/extension_declaration2.png
Diff not rendered.
Binary file removed assets/for-in_statement.png
Diff not rendered.
Binary file removed assets/forced-Value_expression.png
Diff not rendered.
Binary file removed assets/function_call_expression1.png
Diff not rendered.
Binary file removed assets/function_call_expression2.png
Diff not rendered.
Binary file removed assets/function_declaration.png
Diff not rendered.
Binary file removed assets/function_declaration2.png
Diff not rendered.
Binary file removed assets/function_type.png
Diff not rendered.
Binary file removed assets/generic-argument-list.png
Diff not rendered.
Binary file removed assets/generic-parameter-list.png
Diff not rendered.
Binary file removed assets/generic-where-clauses.png
Diff not rendered.
Binary file removed assets/guard_statement.png
Diff not rendered.
Binary file removed assets/if_compiler_statement.png
Diff not rendered.
Binary file removed assets/if_else_statement.png
Diff not rendered.
Binary file removed assets/if_elseif_compiler_statement.png
Diff not rendered.
Binary file removed assets/if_elseif_statement.png
Diff not rendered.
Binary file removed assets/if_statement.png
Diff not rendered.
Binary file removed assets/implicit_member_expression.png
Diff not rendered.
Binary file removed assets/import_declaration.png
Diff not rendered.
Binary file removed assets/import_declaration2.png
Diff not rendered.
Binary file removed assets/infix_operator_declaration.png
Diff not rendered.
Binary file removed assets/initializer_declaration.png
Diff not rendered.
Binary file removed assets/initializer_declaration2.png
Diff not rendered.
Binary file removed assets/initializer_expression.png
Diff not rendered.
Binary file removed assets/inout_expression.png
Diff not rendered.
Binary file removed assets/introduced.png
Diff not rendered.
Binary file removed assets/key-path_expression.png
Diff not rendered.
Binary file removed assets/key-path_string_expression.png
Diff not rendered.
Binary file added assets/[email protected]
Binary file added assets/[email protected]
Binary file added assets/[email protected]
Binary file added assets/[email protected]
Binary file added assets/[email protected]
Binary file added assets/[email protected]
Binary file added assets/[email protected]
Binary file added assets/[email protected]
Binary file added assets/[email protected]
Binary file added assets/[email protected]
Binary file added assets/[email protected]
Binary file added assets/[email protected]
Binary file removed assets/message.png
Diff not rendered.
Binary file removed assets/multipleline_strings.png
Diff not rendered.
Binary file removed assets/obsoleted.png
Diff not rendered.
Binary file removed assets/opaque_type.png
Diff not rendered.
Binary file removed assets/optional-chaining_expression.png
Diff not rendered.
Binary file removed assets/parameter_names.png
Diff not rendered.
Binary file removed assets/parameter_names2.png
Diff not rendered.
Binary file removed assets/postfix_operator_declaration.png
Diff not rendered.
Binary file removed assets/postfix_self_expression.png
Diff not rendered.
Binary file removed assets/precedence_group_declaration.png
Diff not rendered.
Binary file removed assets/prefix_operator_declaration.png
Diff not rendered.
Binary file removed assets/protocol_compose_type.png
Diff not rendered.
Binary file removed assets/protocol_declaration.png
Diff not rendered.
Binary file removed assets/protocol_property_declaration.png
Diff not rendered.
Binary file removed assets/protocol_subscript_declaration.png
Diff not rendered.
Binary file removed assets/regex-literal-1.png
Diff not rendered.
Binary file removed assets/regex-literal-2.png
Diff not rendered.
Binary file removed assets/renamed.png
Diff not rendered.
Binary file removed assets/repeat-while_statement.png
Diff not rendered.
Binary file removed assets/return_statement.png
Diff not rendered.
Binary file removed assets/selector_expression.png
Diff not rendered.
Binary file removed assets/self_expression.png
Diff not rendered.
Binary file removed assets/singleline_strings.png
Diff not rendered.
Binary file removed assets/sourceLocation_compiler_statement.png
Diff not rendered.
Binary file removed assets/special_kinds-of_parameters.png
Diff not rendered.
Diff not rendered.
Binary file removed assets/string_delimited_by_extended_delimiters.png
Diff not rendered.
Binary file removed assets/structure_declaration.png
Diff not rendered.
Binary file removed assets/subscript_declaration.png
Diff not rendered.
Binary file removed assets/subscript_expression.png
Diff not rendered.
Binary file removed assets/superclass_expression.png
Diff not rendered.
Binary file removed assets/switch_statement.png
Diff not rendered.
Binary file removed assets/ternary_conditional_operator.png
Diff not rendered.
Binary file removed assets/throw_statement.png
Diff not rendered.
Binary file removed assets/throwing_functions_and_methods.png
Diff not rendered.
Binary file removed assets/try!_operator.png
Diff not rendered.
Binary file removed assets/try_hatena_operator.png
Diff not rendered.
Binary file removed assets/try_operator.png
Diff not rendered.
Binary file removed assets/tuple_expression.png
Diff not rendered.
Binary file removed assets/type-casting_patterns.png
Diff not rendered.
Binary file removed assets/type-parameter-constraint.png
Diff not rendered.
Binary file removed assets/type_alias_declaration.png
Diff not rendered.
Binary file removed assets/type_casting_operator.png
Diff not rendered.
Binary file removed assets/variable_declaration.png
Diff not rendered.
Binary file removed assets/while_statement.png
Diff not rendered.
6 changes: 5 additions & 1 deletion language-guide/closures.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ var reversedNames = names.sorted(by: backward)

クロージャ式の構文には、次の一般的な形式があります:

![クロージャ式構文](../assets/07_closureexpressionsyntax.png)
```swift
{ (<#parameters#>) -> <#return type#> in
<#statements#>
}
```

クロージャ式構文のパラメータは、in-out パラメータをとることもできますが、デフォルト値を設定することはできません。可変長パラメータに名前を付けると、可変長パラメータを使用できます。タプルも、パラメータの型および戻り値の型として使用できます。

Expand Down
8 changes: 6 additions & 2 deletions language-guide/collection-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ var sixDoubles = threeDoubles + anotherThreeDoubles

配列リテラルからも配列を初期化できます。これは、1 つ以上の要素を持った配列コレクションの簡略記法です。配列リテラルはカンマ区切りの角括弧\(`[]`\)で囲んだ値のリストです:

![Array Literal](../assets/arrayliteral_2x.png)
```swift
[<#value 1#>, <#value 2#>, <#value 3#>]
```

下記の例は、`String` を保持する `shoppingList` という配列を作成しています。

Expand Down Expand Up @@ -475,7 +477,9 @@ namesOfIntegers = [:]

_キーバリューペア_は、キーとバリューの組み合わせです。辞書リテラルは、それぞれのキーバリューペアのキーとバリューをコロン\(`:`\)で分けます。複数のキーバリューペアは、カンマ\(`,`\)区切りのリストを角括弧\(`[]`\)で囲みます:

![&#x8F9E;&#x66F8;&#x306E;&#x4F5C;&#x6210;](../assets/04_dictionarycreating.png)
```swift
[<#key 1#>: <#value 1#>, <#key 2#>: <#value 2#>, <#key 3#>: <#value 3#>]
```

下記の例では、国際空港の名前を保持する辞書を作成します。この辞書は、3 文字の国際空港コードをキーに、空港名をバリューにしています。

Expand Down
38 changes: 33 additions & 5 deletions language-guide/control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ for tickMark in stride(from: 3, through: hours, by: hourInterval) {

`while` ループの基本的な書き方は下記の通りです:

![While&#x30EB;&#x30FC;&#x30D7;](../assets/05_whileform.png)
```swift
while <#condition#> {
<#statements#>
}
```

下記の例は、_蛇とはしご_と呼ばれるシンプルなゲームの例です。

Expand Down Expand Up @@ -184,7 +188,11 @@ print("ゲームオーバー!")

下記が `repeat-while` ループの一般的な形式です。

![repeat-while](../assets/05_repeatwhile.png)
```swift
repeat {
<#statements#>
} while <#condition#>
```

ここで蛇とはしごの例を `while` の代わりに `repeat-while` を使用して書き換えてみます。`finalSquare`、`board`、`square` と `diceRoll` は `while` と全く同じ方法で初期化します。

Expand Down Expand Up @@ -362,7 +370,17 @@ let weatherAdvice = if temperatureInCelsius > 100 {

最もシンプルな形式として、`switch` 文は同じ型の 1 つ以上の値を比較します。

![switch](../assets/05_switchform.png)
```swift
switch <#some value to consider#> {
case <#value 1#>:
<#respond to value 1#>
case <#value 2#>,
<#value 3#>:
<#respond to value 2 or 3#>
default:
<#otherwise, do something else#>
}
```

全ての `switch` 文は、`case` キーワードで始まる複数の可能性があるケースで構成されます。特定の値の比較に加えて、さらに複雑なパターンマッチをケースに指定するための様々な方法を提供しています。この章で後ほど記載しています。

Expand Down Expand Up @@ -711,7 +729,11 @@ Swift では、より複雑な制御フローを作成するために、ルー

ラベル付き文は、文の導入キーワードの前にコロン\(`:`\)を付けて同じ行にラベルを配置することで示せます。下記は、`while` ループの構文の例ですが、他の全てのループや `switch` にも同じ原則が当てはまります。

![&#x30E9;&#x30D9;&#x30EB;&#x4ED8;&#x304D;&#x6587;](../assets/05_lebeledstatements.png)
```swift
<#label name#>: while <#condition#> {
<#statements#>
}
```

次の例は、この章の前で見てきた「蛇とはしご」にラベル付き `while` ループと `break` と `continue` 文を適用したバージョンです。今回は、追加のルールがあります。

Expand Down Expand Up @@ -873,7 +895,13 @@ if #available(iOS 10, macOS 10.12, *) {

基本的な形式として、アベイラビリティ条件はプラットフォームの名前とバージョンのリストを受け取ります。`iOS`、`macOS`、`watchOS`、`tvOS` などをプラットフォームの名前として使います。全リストは[宣言属性\(Declaration Attributes\)](../language-reference/attributes.md)を参照ください。`iOS 8` や `macOS 10.10` のようなメジャーバージョンに加え、`iOS 11.2.6` や `macOS 10.13.3` のようにマイナーバージョンも指定できます。

![API&#x30A2;&#x30D9;&#x30A4;&#x30E9;&#x30D3;&#x30EA;&#x30C6;&#x30A3;&#x6761;&#x4EF6;](../assets/05_availabilitycondition.png)
```swift
if #available(<#platform name#> <#version#>, <#...#>, *) {
<#statements to execute if the APIs are available#>
} else {
<#fallback statements to execute if the APIs are unavailable#>
}
```

`guard` 文でアベイラビリティ条件を使用すると、そのコードブロック内の残りのコードに使用されるアベイラビリティ情報が絞り込まれます。

Expand Down
15 changes: 14 additions & 1 deletion language-guide/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,20 @@ struct PurchasedSnack {

`do-catch` 文の一般的な形式は次のとおりです:

![do catch&#x6587;](../assets/17_errorHandling.png)
```swift
do {
try <#expression#>
<#statements#>
} catch <#pattern 1#> {
<#statements#>
} catch <#pattern 2#> where <#condition#> {
<#statements#>
} catch <#pattern 3#>, <#pattern 4#> where <#condition#> {
<#statements#>
} catch {
<#statements#>
}
```

その句が処理できるエラーを示すには、`catch` の後にパターンを記述します。`catch` 句にパターンがない場合、句は全てのエラーに一致し、エラーを `error` という名前のローカル定数にバインドします。パターンマッチングの詳細については、[Patterns\(パターン\)](../language-reference/patterns.md)を参照ください。

Expand Down
12 changes: 10 additions & 2 deletions language-guide/initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,19 @@ convenience イニシャライザは二次的なもので、クラスのイニ

クラスの指定イニシャライザは、値型のシンプルなイニシャライザと同じ方法で記述します:

![&#x6307;&#x5B9A;&#x30A4;&#x30CB;&#x30B7;&#x30E3;&#x30E9;&#x30A4;&#x30B6;](../assets/14_designatedInitializer.png)
```swift
init(<#parameters#>) {
<#statements#>
}
```

covenience イニシャライザは同じスタイルで記述できますが、`init` キーワードの前にスペース区切りで `covenience` 修飾子を配置します:

![covenience &#x30A4;&#x30CB;&#x30B7;&#x30E3;&#x30E9;&#x30A4;&#x30B6;](../assets/14_convenienceInitializer.png)
```swift
convenience init(<#parameters#>) {
<#statements#>
}
```

### <a id="initializer-delegation-for-class-types">クラス型のイニシャライザの委譲\(Initializer Delegation for Class Types\)</a>

Expand Down
Loading