File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 1
1
package scala
2
2
import compiletime .ops .boolean .*
3
+ import compiletime .summonAll
3
4
4
5
import language .experimental .captureChecking
5
6
@@ -209,6 +210,14 @@ object NamedTupleDecomposition:
209
210
/** An immutable array consisting of all element values */
210
211
inline def toIArray : IArray [Object ] = x.toTuple.toIArray
211
212
213
+ /** An immutable map consisting of all element values.
214
+ * Keys are the names of the elements.
215
+ */
216
+ inline def toMap : collection.Map [String , Tuple .Union [V ]] =
217
+ summonAll[Tuple .Map [N , ValueOf ]].toList
218
+ .map(_.asInstanceOf [ValueOf [? <: String ]].value)
219
+ .lazyZip(x.toList)
220
+ .toMap
212
221
end extension
213
222
214
223
/** The names of a named tuple, represented as a tuple of literal string values. */
You can’t perform that action at this time.
0 commit comments