👋

Go言語における式の評価文脈を理解する

に公開
2

Discussion

Hajime HoshiHajime Hoshi

(他にもあったら教えてください)

仕様によると blank identifier の場合もそうなるようです

https://golang.org/ref/spec#Assignments

If an untyped constant is assigned to a variable of interface type or the blank identifier, the constant is first implicitly converted to its default type.

あとは switch 文:

https://golang.org/ref/spec#Switch_statements

If the switch expression evaluates to an untyped constant, it is first implicitly converted to its default type;

DQNEODQNEO

Hoshi さん ご指摘ありがとうございます!

blank identifier

the blank identifier への代入ということは値が捨てられるだけなのに、型の仕様がちゃんと明記されてるのが面白いですね。

switch 文:

見逃してました。追記しておきます。