Dynamically Typed Swift, Built on Regular Swift.
(Work in Progress, Not Ready for Production)
Support arrays with variadic arguments of mixed types, enabling the creation of flexible and dynamically typed collections.
let diverseArray = [1, "two", 3.5, (name: "Alex", age: 29)]
let person = (name: "Jordan", age: 35,
interests: ["Hiking", "Photography"])
func printArrayElements(array) {
for element in array {
switch element {
case let int as Int:
print("Int: \(int)")
case let str as String:
print("String: \(str)")
case let tuple as (name: String, age: Int):
print("Person: \(tuple.name), Age: \(tuple.age)")
default:
print("Unknown Type")
}
}
}
Accept an indefinite number of arguments
func combineElements(args...) {
var combinedString = ""
for arg in args {
combinedString += "\(arg) "
}
print(combinedString)
}