Closed BenchR267 closed 7 years ago
@BenchR267 enums with raw values are automatically ValueType
s.
Look for RawRepresentable
in MarshaledObject.swift to see how this is done.
Ah thanks, that explains the message. In this case this works great, but I have another enum with a slightly more complex mapping logic. Is it somehow possible to overwrite the behaviour?
I can't think of a way to do that short of what you're already doing (pull out the raw value and do the mapping). We would need to add something like this to achieve what you want: https://github.com/utahiosmac/Marshal/issues/73#issuecomment-258433175
Yeah, that would solve this case. Thanks for your answers! I'll close this issue since my original question is answered. 😸
Hi!
I experienced a small problem when using enums as ValueTypes. I have an enum in a project defined as the following:
I implemented the ValueType extension as the following:
When using this in a type that has a
Week
property, I get the compiler error 'ambiguous use of X' where X is either <| or value(for:).I fixed it by using this code in my type that is using
Week
, but the solution is not that satisfiying. Do you have any other ideas?Thanks in advance!