Skip to content

fix issue 5 & 6#14

Open
ruby109 wants to merge 1 commit intoZhipingYang:masterfrom
ruby109:develop
Open

fix issue 5 & 6#14
ruby109 wants to merge 1 commit intoZhipingYang:masterfrom
ruby109:develop

Conversation

@ruby109
Copy link
Copy Markdown

@ruby109 ruby109 commented Dec 18, 2019

There is no need to use PrettyRawRepresentable unless you want to specify the type. Using extension can do the same thing and pass tests.
If you still want to use PrettyRawRepresentable, you can write it like this

public protocol PrettyRawRepresentable: RawRepresentable{

}

public extension PrettyRawRepresentable where RawValue == String {
    var prettyRawValue: String {
        let paths = String(reflecting: self).splitWithoutFirst()
        if String(paths.last ?? "") != rawValue {
            return rawValue
        }
        return paths.joined(separator: "_")
    }
}

public extension PrettyRawRepresentable {
    var prettyRawValue: String {
        return String(reflecting: self).splitWithoutFirst().joined(separator: "_")
    }
}

In issue 6, instead of using rawValue, you can use prettyRawValue to get the correct Info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant