Skip to content

Instantly share code, notes, and snippets.

@djds23
Created February 9, 2019 17:16
Show Gist options
  • Save djds23/9ae8681d052dd4b887dcb1faa112879a to your computer and use it in GitHub Desktop.
Save djds23/9ae8681d052dd4b887dcb1faa112879a to your computer and use it in GitHub Desktop.
import Foundation
enum MovieGenre: Int, Codable {
case action, horror, art, comedy, drama
}
let genre: MovieGenre = .action
let encoder = JSONEncoder()
// On the follow line, the code raises Swift.EncodingError.invalidValue
let jsonValue = try! encoder.encode(genre)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment