DEV Community

loading...

Discussion on: Daily Challenge #1 - String Peeler

Collapse
hevivekm profile image
Vivek

Swift - 5

var str = "Hello, playground"
func stringPeeler(input: String) -> String? {
    if (input.count <= 2) {
        return nil;
    }

    return String(input.dropLast().dropFirst())
}

print(stringPeeler(input: str)!)
Forem Open with the Forem app