blob: fcfebe2ea84c7bac776c37b6c165a0de8fd92dca [file] [log] [blame]
class MapLike<K, V> {
final Map<K, V> _map = {};
V? get(Object key) => _map[key];
V put(K key, V value) => _map[key] = value;
}
extension Extension<K, V> on MapLike<K, V> {
V? operator [](Object key) => get(key);
void operator []=(K key, V value) => put(key, value);
}
class MapLike2<K, V> {
final Map<K, V> _map = {};
final V defaultValue;
MapLike2(this.defaultValue);
V get(Object key) => _map[key] ?? defaultValue;
V put(K key, V value) => _map[key] = value;
}
extension Extension2<K, V> on MapLike2<K, V> {
V operator [](Object key) => get(key);
void operator []=(K key, V value) => put(key, value);
}
main() {}
implicit() {}
explicitWithTypeArguments() {}
explicitInferredTypeArguments() {}
expect(expected, actual) {}