前提・実現したいこと
Xcode ver.11.3でswiftの勉強をしています。(.praygroundファイル)
エラーと警告の発生原因と対策を詳しく知りたいです。
発生している問題・エラーメッセージ
Initialization of immutable value 'comment' was never used; consider replacing with assignment to '_' or removing it Replace 'let comment' with '_' Use of unresolved identifier 'comment'
該当のソースコード
swift
1var number = 3 2switch number { 3 case 1: 4 let comment = "small" 5 default: 6 let comment = "big" 7} 8print(comment)
試したこと
var number = 3 switch number { case 1: let comment = "small" print(comment) default: let comment = "big" print(comment) }
こうする事でエラーと警告は消えたが、なぜ該当のソースコードではエラーと警告がでて、print
が実行されないのかがわからないです。
回答2件
あなたの回答
tips
プレビュー