Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue 5 & 6 #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fix issue 5 & 6 #14

wants to merge 1 commit into from

Conversation

ruby109
Copy link

@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