readonly arrays

I don't get what the is the point, you can use readonly 100% in your code, if we give back an array that is mutable it is perfectly assignable to a readonly, and you can do so by both specifing the type or using a readonly combinator. The opposite is not true, when a user wants to use the returned values mutably specifying the type is not enough, and there is noting wrong in mutating the result of a computation that returns a fresh copy, a thing that we have to do anyway because readonly doesn't prevent the input. In every module the perfect tradeoff for usability is having inputs as weak as possible, i.e. Iterable<A> for things like arrays because inputs are contravariant and return types as powerful as possible because outputs are covariant
Was this page helpful?