0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Swift】 基本構文

Last updated at Posted at 2020-06-25

変数の宣言

Variable.swift
 // 型も宣言する場合
 var 変数名: = 
 var age: Int = 20
 
 // 型推論が行われる場合
 var 変数名 = 
 var age = 20
 
 // 値を入れない(初期値nil)場合(オプショナル型)
 var 変数名: !
 var age: Int!

定数の宣言

Constant.swift
 // 型も宣言する場合
 let 変数名: = 
 let age: Int = 20
 
 // 型推論が行われる場合
 let 変数名 = 
 let age = 20
 
 // 値を入れない(初期値nil)場合(オプショナル型)
 let 変数名: !
 let age: Int!

メソッドの定義

Method.swift
 func メソッド名(第一引数名: , 第2引数名: ) -> 戻り値の型{
     return num1 + num2
 }
 
 func plus(num1: Int, num2: Int) -> Int {
 	return num1 + num2
 }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?