I play with Swift, trying to make it look more "dynamically typed" - just for fun, the expected production is not expected.
Now I'm stuck in rewriting the behavior of converting inline types to String.
For example, I would like to see this output for Array:
let nums = [1, 2, 3]
print(nums)
So far i tried
- make extension to
NSArray(not compiled) - implement
CustomStringConvertible(not compiled) - make an extension to
Array(compiles, does not change anything)
It seems like I'm wrong:
extension Array {
public var description: String { return "An array" }
}
How is this possible in Swift?
Any ideas?
source
share