Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Swift Overloading with Different Parameter Types

// function with Int type parameter
func displayValue(value: Int) {
    print("Integer value:", value)
}

// function with String type parameter
func displayValue(value: String) {
    print("String value:", value)
}

// function call with String type parameter
displayValue(value: "Swift")

// function call with Int type parameter
displayValue(value: 2)
 
PREVIOUS NEXT
Tagged: #Swift #Overloading #Different #Parameter #Types
ADD COMMENT
Topic
Name
9+5 =