Using prefix
and ?: as a one-liner
func right(value: String, length: Int) -> String {
return value.count > length ? String(value.prefix(value.count - length)) : value
}
solved Check if passed argument value is nil or empty
Using prefix
and ?: as a one-liner
func right(value: String, length: Int) -> String {
return value.count > length ? String(value.prefix(value.count - length)) : value
}
solved Check if passed argument value is nil or empty