google / tuple.dart

A library providing a tuple data structure
https://pub.dev/packages/tuple
BSD 2-Clause "Simplified" License
194 stars 26 forks source link

Should this package be deprecated/unlisted? #45

Closed JaffaKetchup closed 1 year ago

JaffaKetchup commented 1 year ago

With the release of Dart 3.0 comes records. This pretty much does the same as this package, but has more advantages as it is more closely tied in with the other features of the language.

Is this package necessary anymore?

oprypin commented 1 year ago

While we are here- In the world of records, is there an actual convenient alternative to withItemN methods? E.g.

https://github.com/google/tuple.dart/blob/aac8fae64980f7c006109d850adfd36fcd09f49d/lib/tuple.dart#L154-L156

Or is there any way to write equivalent utility functions for records?

JaffaKetchup commented 1 year ago

Hey, it's the nightly.link guy :D

Turns out, you are quite right. Records are immutable, and there's no built in way to copy them or iterate through their elements - you'd need something like (original.$1, 'new', original.$2). Can't even use the spread operator. I hadn't used them myself yet, but would've assumed they'd have a few more functions than they do.

Maybe that in itself is enough reason for Tuples to keep existing.