reference_wrapper 1.0.0 copy "reference_wrapper: ^1.0.0" to clipboard
reference_wrapper: ^1.0.0 copied to clipboard

A Dart package which simulates pass by reference feature.

example/reference_wrapper_example.dart

import 'package:reference_wrapper/reference_wrapper.dart';

void twice(Ref<num> x, Ref<num> y) {
  x.ref *= 2;
  y.ref *= 2;
}

void twiceAdvanced(Ref<num> x, Ref<num> y) {
  x(x() * 2);
  y(y() * 2);
}

void main() {
  var x = Ref<num>(5);
  var y = Ref<num>(7);

  twice(x, y);
  print(x.ref); // 10
  print(y.ref); // 14

  twiceAdvanced(x, y);
  print(x()); // 20
  print(y()); // 28
}
2
likes
150
points
3
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart package which simulates pass by reference feature.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on reference_wrapper