Swift - Variables and Constants
Identify the error in the following Swift code snippet:
typealias Name = String
func greet(name: Name) {
print("Hello, \(Name)!")
}
greet(name: "Alice")Identify the error in the following Swift code snippet:
typealias Name = String
func greet(name: Name) {
print("Hello, \(Name)!")
}
greet(name: "Alice")name, but inside print, Name (the type alias) is used instead.Name is a type alias, not a variable holding the value. The print should use name to print the argument.Name inside the print instead of the parameter name -> Option A15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions