「Swift5」関数で引数無しのサンプル

2021年3月31日

書式
関数名->戻り型
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
//引数なし 関数の定義
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

Swift

Posted by arkgame