Is the `?` symbol overloaded?

If you add ? attribute-name after an attribute set it returns either true or false depending on whether the attribute set contains a key with the given attribute name[0]. But if you add ? value after an attribute key you define a default value for the key[1].

Is the ? symbol overloaded, and its meaning change between contexts; or does it have an abstract definition that make it behave this way?

Hope I’ve mad my question clear!

Yes it is overloaded as in the same symbol is used for two things.

I want to clarify that this only works in the function parameter, so the two uses only appear in different places, therefore this is correct:

1 Like

I sometimes with the one in expressions was ??, as most bool-returning operators are two characters.

What do you mean? I don’t understand what you wrote.

He meant “I sometimes wish”.

4 Likes