Skip to content

Conversation

road21
Copy link
Contributor

@road21 road21 commented Aug 27, 2025

There already are methods toArray, toList for NamedTuple for collecting elements into collections.
I would like to add method toMap where keys are names of the elements.

For example:

(x = 1, y = true).toMap // Map("x" -> 1, "y" -> true)

One obvious usage of this method is debugging code with named tuples (standard toString method doesn't show names):

println((x = 1, y = true)) // prints (1, true)
println((x = 1, y = true).toMap) // prints Map(x -> 1, y -> true)

@road21 road21 requested a review from a team as a code owner August 27, 2025 12:50
@Gedochao Gedochao requested a review from aherlihy August 27, 2025 13:03
@road21 road21 force-pushed the feature-named-tuples-to-map-std branch from e908ff4 to 0387869 Compare August 27, 2025 16:49
@He-Pin
Copy link
Contributor

He-Pin commented Sep 1, 2025

Will there be a toListMap

@road21 road21 force-pushed the feature-named-tuples-to-map-std branch from 0d8a36c to 37b4759 Compare September 2, 2025 08:45
@road21
Copy link
Contributor Author

road21 commented Sep 2, 2025

Will there be a toListMap

I think toListMap is enough, fixed to toListMap

@road21 road21 force-pushed the feature-named-tuples-to-map-std branch from 37b4759 to 25bf111 Compare September 2, 2025 08:47
@road21
Copy link
Contributor Author

road21 commented Sep 2, 2025

@aherlihy could you please take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants