I want to remove some models in tuple “dropm”, from a list of models “mList”.
This fails when the tuple “dropm” is a singleton. It only works if “dropm” is a Vector{string}.
I want it to work if “dropm” is a tuple.
dropm = (“m2”) is not creating a tuple, the brackets don’t do anything here, so dropm is just the string "m2". You are probably looking for dropm = (“m2”,). The comma is necessary here, since otherwise this can’t be distinguished from brackets only used for precedence like in (1 + 2) * 3, for example.
Thank you @simeonschaub!
Then there is a slight generality annoyance.
To make a vector of strings, the syntax is identical whether it is a singleton or not:
dropm = ["m2", "m1"] #= VS =# dropm = ["m2"]
But to make a tuple, the syntax is different when the tuple is a singleton:
I understand the frustration, but there’s not really anything that can be done here. Like I explained above, in a case like (1 + 2) * 3 it would otherwise be ambiguous, whether you mean a tuple containing only 3 or simply the integer 3 times 3, since brackets can also be used just to establish mathematical precedence, e.g. which function should be evaluated first.
I think that would be much more confusing than the current behavior. The way syntax is parsed shouldn’t really depend on any type information. Otherwise it would be really hard to explain to people, why ("a") is completely different to (2). You can also just as well use infix operators with strings, so in expressions like ("a" * "b")^3, the brackets still have an important purpose.