mapInPlace method

void mapInPlace(
  1. T convert(
    1. T
    )
)

Maps every element using convert, in-place.

Set không thể mutate theo index nên cần tạo set mới.

final s = Ref({'a', 'bb'});
s.mapInPlace((e) => e.length); // -> {1, 2}

Implementation

void mapInPlace(T Function(T) convert) {
  final newSet = $.map(convert).toSet();
  $.clear();
  $.addAll(newSet);
  notifyChange();
}