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

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