Complete the code to declare a generic function that returns the same type it receives.
func identity<T>([1]: T) -> T { return value }
The parameter name value matches the return type T and is used inside the function.
Complete the code to declare a generic struct with a property of generic type.
struct Box<[1]> {
var content: T
}The generic type parameter T is used to define the type of the property content.
Fix the error in the generic function declaration by completing the missing generic type parameter.
func swapValues<[1]>(_ a: inout T, _ b: inout T) {
let temp = a
a = b
b = temp
}The generic type parameter T must be declared to match the parameter types.
Fill both blanks to create a generic function that compares two values of the same type.
func areEqual<[1]>(_ a: [2], _ b: T) -> Bool { return a == b }
The generic type parameter T is declared and used as the type of both parameters to ensure they are the same type.
Fill all three blanks to create a generic function that returns the first element of an array of any type.
func firstElement<[1]>(of array: [[2]]) -> [3]? { return array.first }
The generic type parameter T is declared and used consistently for the array element type and the return type.