Commit a3e2b17
authored
named tuple toMap extension method (#23827)
There already are methods `toArray, toList` for `NamedTuple` for
collecting elements into collections.
I would like to add method `toSeqMap` where keys are names of the
elements.
For example:
```scala
(x = 1, y = true).toSeqMap // SeqMap("x" -> 1, "y" -> true)
```
One obvious usage of this method is debugging code with named tuples
(standard `toString` method doesn't show names):
```scala
println((x = 1, y = true)) // prints (1, true)
println((x = 1, y = true).toSeqMap) // prints SeqMap(x -> 1, y -> true)
```File tree
2 files changed
+17
-4
lines changed- library/src/scala
- tests/run
2 files changed
+17
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | | - | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
212 | 222 | | |
213 | 223 | | |
214 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | | - | |
86 | | - | |
87 | | - | |
| 86 | + | |
| 87 | + | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
0 commit comments