Require parameter names for ENUM Associated Types?

(Braeden Profile) #1

Just another question for the examples…is an overloaded case even the right way to think of it? Enums give a selection between different cases, with optional payloads. With this…

enum JSONValue
  case otherStuff1
  case foo
  case javaScript(String)
  case javaScript(String, scope: Document) // part of the same case?

if case .javaScript = myJSON
  { }

We can represent the difference in data, yes, but are these actually separate cases? I think that default values make this case better because `javaScript` really is only one case, and both types of JSONValue are the same, to me. Saying they are the same case, I think that would necessitate the same payload type.