Swift part13 (412レス)
前次1-
抽出解除 レス栞

リロード規制です。10分ほどで解除するので、他のブラウザへ避難してください。
404
(1): デフォルトの名無しさん (ワッチョイ eb01-v8wM) [sage] 2025/06/10(火) 23:17:17.93 ID:HzGLhqs50(1) AAS
>>399
399(1): デフォルトの名無しさん (ワッチョイ fb08-G4JC) [] 2025/06/10(火) 21:15:44.74 ID:co9N3dhx0(2/4) AAS
private test_func_name: String!
func test_func(function: () -> Void) -> String {
function()
let test: String = test_func_name
return(test)
}

func test_func1() -> Void {
test_func_name = #function
return()
}

func test_func2() -> Void {
test_func_name = #function
return()
}

print(test_func(function: test_func1())) //test_func1 出力
print(test_func(function: test_func2())) //test_func2 出力

--
>>398
> test_func(function: test_func1, name: “test_func1”)
これって、スペルミスしやすいですよね

上記の方が、まだマシな気はします

根本的に
関数の引数に関数を指定した場合、引数の関数名を取得
は不可ってことでしょうか
>これって、スペルミスしやすいですよね
だからマクロ・・・・・

>>402
402(2): デフォルトの名無しさん (ワッチョイ 0bcd-JxoL) [sage] 2025/06/10(火) 22:15:58.52 ID:povNpgQm0(1) AAS
>Swift is a statically dispatched programming language.
>This results in Swift using memory addresses as much as possible when it needs to call a function.
>The side effect is the inability to capture the called function name, since in most of the cases it will be a simple memory address.
@objc属性つければ事情が変わる
406
(1): デフォルトの名無しさん (ワッチョイ fb6a-G4JC) [] 2025/06/11(水) 08:54:28.08 ID:Y6NiPAiA0(2/3) AAS
>>404
マクロにしても...

すいませんが、サンプルコーディングみせてもらえませんか
お願いします
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 0.031s