I have a function for which one of the arguments may be either an array or a tuple, though its usage internally is tuple-like. If x is an array that then I will have the line
y = copy(x)
but if x is a tuple, copy will not work so I need to simply say:
y = x
The problem is: how can my code distinguish the two? I tried using typeof()
, but that does not return a string, so I do not know how to interrogate the result of typeof()
. (I looked at https://docs.julialang.org/en/v1/manual/types/ but I cannot find anything there on how to process the output of typeof()
).
EDIT: never mind, a “splat” seems to work on either:
y = tuple(x...)
EDIT 2: So I will delete this in a while unless someone asks to keep it.
13 posts - 6 participants