search

Home  >  Q&A  >  body text

swift4.2 dictionary problem

Help heroes: I recently watched a video to learn Swift, but when I practiced it myself, I found that the video was a little different from the actual practice. For example, when I learned arrays and dictionaries, I found the following problems:

import Foundation

//import Cocoa

//var dict:[String:String]=["name":"jack","age":"22"]

var dict=["name":"jack","age":"22"]

print(dict)

print(dict[" name"])//Warning here: Expression implicitly coerced from 'String?' to 'Any'

The output results are also different from the video, please give me some advice

BrianRawlingsBrianRawlings2280 days ago1146

reply all(0)I'll reply

No reply
  • Cancelreply