google/tuple.dart

Common interface

Closed this issue · 5 comments

It would it very convenient to have a common interface for tuple : Tuple

So you can store List but add different implementations.
Currently I need to strongly type on Tuple2 but some result got more entries.

This interface Tuple can gives you the number of index (arity) and allow access to value by index and an iterator.

Thank you !

Indeed it would great to know if a value is Tuple without having to check each type one by one (is Tuple2, is Tuple3...). It could also a share the common toList method they all have:

/// Represents a tuple.
abstract class Tuple {
  /// Creates a [List] containing the items of this [Tuple].
  ///
  /// The elements are in item order. The list is variable-length
  /// if [growable] is true.
  List toList({bool growable = false});
}

Thanks for the information @Solido. Is there any place I could look for more information (current status, planned implementation) as I could not find relevant information so far?