Avatar
Avatar
Iceman
@swift-5.9.2 import Foundation let data = """ "Hello" """.data(using: .utf8)! print(try! JSONDecoder().decode(String.self, from: data)) (edited)
exit status: 1 with <stdin>:5:52: error: value of optional type 'Data?' must be unwrapped to a value of type 'Data' print(try! JSONDecoder().decode(String.self, from: data)) ^ <stdin>:5:52: note: coalesce using '??' to provide a default when the optional value contains 'nil' print(try! JSONDecoder().decode(String.self, from: data)) ^ ?? <#default value#> <stdin>:5:52: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' print(try! JSONDecoder().decode(String.self, from: data)) ^ !