Upload
tomohiro-kumagai
View
953
Download
3
Embed Size (px)
Citation preview
// 型名につけるとメタタイプが得られる let type: Int.Type = Int.self // Int.Type
// 評価式に付けると… 評価結果…? let value: Int = (5 + 3).self // 8
// 普通に計算すれば、掛け算が優先 let a = 1 + 2 * 5 // 11
// 評価式の一部を.self で括ると… let b = (1 + 2).self * 5 // 15
// でも.self がなくても同じ? let c = (1 + 2) * 5 // 15
// 先に評価なら、このように Int 型になりそうだが let a = (1 + 2) as Int * 3.5
// リテラルのまま存続して Double 型に落ち着く let b = (1 + 2).self * 3.5 // 10.5
Binary operator '*' cannot be applied to operands of type 'Int' and 'Double'