[RFC] Expand Tuple.from and Tuple#from to accept Tuple #10080
Labels
kind:bug
A bug in the code. Does not apply to documentation, specs, etc.
kind:feature
topic:compiler:codegen
topic:stdlib:collection
Proposed Changes
This would extend the parameters to accept a Tuple as well as Array. A working example
Expand Diff
Motivation
As with all my crystal coding in December, this starts with Advent of Code. I wished to map an
Array(Int32?) to an
Array(Tuple(Int32, Int32))` that included the index from the original array.Something akin to this.
This did work for removing the elements but didn't work for different reasons to do with being unable to cast from one Tuple type to another so it remained an
Array(Tuple(Int32?, Int32))
. Can deal with that, of course, but it could be cleaner. This lead me to a rabbit hole of casting Tuples and needing to do something like{t[0].as(Int32), t[1]}
I wish this change to allow something like this too, but so far it ends up in an Invalid memory access
Related Issue/PR #10041 #10047
The text was updated successfully, but these errors were encountered: