「Swift5」関数で引数無しのサンプル
書式
関数名->戻り型
使用例
//引数なし 関数の定義
func testFunc() -> String {
return "this is a test"
}
print("関数で引数無しのサンプル")
print(testFunc())
//引数なし 関数の定義
func testFunc() -> String {
return "this is a test"
}
print("関数で引数無しのサンプル")
print(testFunc())
//引数なし 関数の定義 func testFunc() -> String { return "this is a test" } print("関数で引数無しのサンプル") print(testFunc())
結果
$ swift testB.swift
関数で引数無しのサンプル
this is a test