简体   繁体   中英

Is there any advantage at all in Swift if redundant code?

var _name = item["name"] as NSString

VS

var _name: NSString = item["name"] as NSString

Is there any advantage in speed or something behind the scenes in adding the extra : NSString besides readability? If not, why keep it at all?

Is there any advantage in speed or something behind the scenes in adding the extra : NSString besides readability?

No. The compiler infers it anyway. Sometimes the compiler can't infer it, so it's required.

If not, why keep it at all?

Who said you should? Don't.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM