GithubHelp home page GithubHelp logo

Comments (2)

oprypin avatar oprypin commented on September 28, 2024

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

tuple.dart/lib/tuple.dart

Lines 154 to 156 in aac8fae

/// Returns a tuple with the second item set to the specified value.
Tuple4<T1, T2, T3, T4> withItem2(T2 v) =>
Tuple4<T1, T2, T3, T4>(item1, v, item3, item4);

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

from tuple.dart.

JaffaKetchup avatar JaffaKetchup commented on September 28, 2024

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.

from tuple.dart.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.