Single-Element Arrays & Explicit Copying of Arrays
It's currently not possible to create an array with only a single element. Any attempt to do so will merely store that array as a string. Which brings us to the question: should we solve this by having array variable lookups fall back to string variable lookups, or follow the Oil shell and make the act of copying an array explicit? If we pursue to make array copying explicit, that would entail an extra step in the let
command to see if the first and last character are [
and ]
respectively, which would designate to store the value in an array. What are your thoughts?
Explicit Array Copying
Personally, I may be leaning more towards this one, myself.
let array = [ 1 ]
let array_copy = [ @array ]
let string = @array
Implicit Array Copying w/ String Fallback
let string = [ 1 ]
echo $string @string # <- Same output for both
let array = [ 1 2 ]
let array_copy = @array
@huntergoldstein @mgmoens @jackpot51