This is essentially the same question as
Julia: Flattening array of array/tuples
but for array of String
s. The Iterators.flatten(xs)
solution shown in the above thread is excellent for numbers. But, with Strings
, Iterators.flatten()
flattens a String
into characters!
julia> f(xs...) = collect(Iterators.flatten(xs))
f (generic function with 1 method)
julia> f("oh", ["a", "b"], "uh")
6-element Vector{Any}:
'o': ASCII/Unicode U+006F (category Ll: Letter, lowercase)
'h': ASCII/Unicode U+0068 (category Ll: Letter, lowercase)
"a"
"b"
'u': ASCII/Unicode U+0075 (category Ll: Letter, lowercase)
'h': ASCII/Unicode U+0068 (category Ll: Letter, lowercase)
How do you get an Array of String
s from a call like f("hello", ["a", "b"], . . .)
?
It would be nice if you can tell the iterator to regard String
as scalar.