If you'd like to stop
xs2.append("yello")
from being possible in that example, I think that what you'd really want is some Array
or any Array
, not [Any]
. You can see the underpinnings of the restrictions that would be applied when Element
is missing:
var xs2: some RangeReplaceableCollection = xs1
xs2.append(4) // Cannot convert value of type 'Int' to expected argument type '(some RangeReplaceableCollection).Element'
var xs2: any RangeReplaceableCollection = xs1
xs2.append(4) // No exact matches in call to instance method 'append'