Swift 3.0 and getting this error, unsure why:
Code:
func rest(_ list: ArraySlice<T>) -> ArraySlice<T> {
return list.dropFirst()
}
Error:
error: repl.swift:1:48: error: use of undeclared type 'T'
func rest(_ list: ArraySlice<T>) -> ArraySlice<T> {
^
You need to specify the generic parameter of ArraySlice
, just using as ArraySlice<T>
does not declare T
:
func rest<T>(_ list: ArraySlice<T>) -> ArraySlice<T> {
return list.dropFirst()
}
Or:
class MyClass<T> {
func rest(_ list: ArraySlice<T>) -> ArraySlice<T> {
return list.dropFirst()
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With