Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a record example using a typedef #4839

Closed
parlough opened this issue May 10, 2023 · 1 comment · Fixed by #6382
Closed

Add a record example using a typedef #4839

parlough opened this issue May 10, 2023 · 1 comment · Fixed by #6382
Labels
a.language Relates to the Dart language tour d.enhancement Improves docs with specific ask e1-hours Can complete in < 8 hours of normal, not dedicated, work fix.examples Adds or changes example from.team Reported by Dash docs team member p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface.

Comments

@parlough
Copy link
Member

A common use case I've already seen is to declare a typedef for a record.

It might be worth documenting a specific example where this makes sense in the typedef and/or the record documentation.

@parlough parlough added d.enhancement Improves docs with specific ask a.language Relates to the Dart language tour p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. fix.examples Adds or changes example e1-hours Can complete in < 8 hours of normal, not dedicated, work labels May 10, 2023
@RandalSchwartz
Copy link

RandalSchwartz commented Jun 5, 2023

Just be careful to emphasize that a typedef is an alias, not a new type.

typedef A = (int a1, String a2);
typedef B = (int b1, String b2);

final A aThing = (14, 'hello');
final B bThing = aThing; // this works!

This works of course because A and B are not really new types... just alias for the records. And records are the same type as long as they have the same shape.

@atsansone atsansone added the from.team Reported by Dash docs team member label Aug 8, 2023
@MaryaBelanger MaryaBelanger linked a pull request Feb 19, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a.language Relates to the Dart language tour d.enhancement Improves docs with specific ask e1-hours Can complete in < 8 hours of normal, not dedicated, work fix.examples Adds or changes example from.team Reported by Dash docs team member p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants