6,013 votesDylan Nicholson supported this idea ·
221 votesDylan Nicholson commented
readonly products = GetProductList();
getOrders().ForEach(o => o.UpdateProductsInformation(products));
There's no guarantee the actual items in the products list won't get changed - just that 'products' is still referring to the same list, so the use of 'readonly' here would potentially be misleading. The guarantee that products still points to the same list is given by the C# convention of pass by value.
Having said that I do like the idea of local readonly "named values" ('variables' would be seem to be an obvious misnomer - I gather they're called 'bindings' or bound identifiers in F#).