I ran across something I don't understand today. Consider the following snippet:
public class EventStreamCollection<TKey, TValue>
{
private readonly ConcurrentDictionary<TKey, TValue> _dictionary = new ConcurrentDictionary<TKey, TValue>();
private readonly Func<TKey, TValue> _factory;
public EventStreamCollection(Func<TKey, TValue> factory)
{
_factory = factory;
}
public TValue this[TKey key] => _dictionary.GetOrAdd(key, _factory);
}
What is this line
public TValue this[TKey key] => _dictionary.GetOrAdd(key, _factory);
It has no name that I can see. If it did, I guess it would be a property? What is it and how does it work?