I am new to Swift so im just trying to solve basic problems, but can't figure out this one.
I am trying to count how many times a String, Int, Double or another class appears. And output the data. Right now i am only outputting the type. This is the code so far:
var myArr = [Any]()
myArr.append("hello")
myArr.append("goodbye")
myArr.append(1)
myArr.append(1.0)
myArr.append(Student())
for item in myArr {
switch item {
case let stringy as String :
print(stringy, type(of: stringy))
case let inty as Int :
print(type(of: inty))
case let doubly as Double :
print(type(of: doubly))
case let student as Student :
print(type(of: student))
default:
print("unknown object")
}
}