When executing join([missing])
, the result is the String "missing"
. Is this intended behavior? I would have expected missing
as a result. Is this by intention?
I think so:
help?> join
search: join joinpath adjoint typejoin isdisjoint
join([io::IO,] iterator [, delim [, last]])
Join any iterator into a single string, inserting the given delimiter (if
any) between adjacent items. If last is given, it will be used instead of
delim between the last two items. Each item of iterator is converted to a
string via print(io::IOBuffer, x). If io is given, the result is written to
io rather than returned as a String.
Examples
≡≡≡≡≡≡≡≡
julia> join(["apples", "bananas", "pineapples"], ", ", " and ")
"apples, bananas and pineapples"
julia> join([1,2,3,4,5])
"12345"
and print(missing)
just prints “missing”, which makes sense, since you would not see any output in the REPL otherwise.
Perhaps you’d like something more like:
julia> mystring(x) = string(x)
mystring (generic function with 1 method)
julia> mystring(::Missing) = missing
mystring (generic function with 2 methods)
julia> mapreduce(mystring, *, [1,2,3,missing])
missing
Just note that this much more inefficient (like O(N^2) scaling) when concatenating strings.
Other idea:
julia> myjoin(itr) = any(ismissing, itr) ? missing : join(itr)
myjoin (generic function with 1 method)
julia> myjoin([1,2,3,missing])
missing