How to renew a listing with another listing

I want to expand the enumeration to others that add new values ​​to the parent.

I have a basic enumeration

enum MyEnum: Int {

  case One = 1
  case Two

}

And I want another listing that should propagate the base values:

enum OtherEnum: MyEnum {

  case Three = 3
  case Four

}

Then the compiler tells me:

error: raw type 'MyEnum' is not convertible from any literal
error: type 'OtherEnum' does not conform to protocol 'RawRepresentable'

In the end I did not work. I want to get into a dead end.

Is it possible? I know this can be done with a class / subclass, but in the end it will be IMO less clear
Thanks

EDIT: I saw this post , but according to the latest Apple Doc , maybe this is now possible. I assume that expanding functionality does not add a new meaning ...

Swift . O , , , , . ; , ; .

+4

Source: https://habr.com/ru/post/1620417/


All Articles