So, me not knowing what ‘?’ is supposed to mean, I hover over the item with my cursor.
The VS Code extension doesn’t like to say me anything, so there could we improve something.
And then, looking up for “operators” or simply “?” directly yields me nothing in the documentation.
I really looked for 15 minutes, there is nothing. At least not something, that I could find.
I also suggest, to provide an overview of ALL operators on one page, or some kind of cheat sheet.
Can you explain me, what this operator does, and how we can improve the documentation?
An info box in VS Code would be by far the best thing.
Congratulations to the docs otherwise, they are overall really good.
Typing ? in the REPL to go to help mode, and then ? as the object to get help on, gives details on the operator with examples:
help output
help?> ?
search: ? ?:
a ? b : c
Short form for conditionals; read "if a, evaluate b otherwise evaluate c". Also known as the ternary operator
(https://en.wikipedia.org/wiki/%3F:).
This syntax is equivalent to if a; b else c end, but is often used to emphasize the value b-or-c which is being used as part of a
larger expression, rather than the side effects that evaluating b or c may have.
See the manual section on control flow for more details.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> x = 1; y = 2;
julia> x > y ? println("x is larger") : println("y is larger")
y is larger
Not sure how VS Code picks up docs or why it doesn’t work for this case.
I do agree with the idea of an overview page listing all the operators. When I was a Perl developer, the special perldoc pages like perldoc perlre (for RegEx), perldoc perlop (for operators), etc. were very useful, a quick and easy reference for comprehensive info.
The Julia manual has a page for mathematical operators, but to find ? : you’d have to go to the Control Flow page which you couldn’t guess if you didn’t know what the operator does in the first place.
There is this cheat sheet, in which ? is mentioned (both as the ternary operator and the way to enter the help> REPL mode). I think such cheat sheets are indeed useful, especially for newcomers.
Can I guess about why this is the case? I assume because it is the only operator, that applies to three different elements?
I dont know, it just seems like an obvious difference to all the others, and so I assumed, this might be related? Or why is this implemented differently?
True. On a more serious note, I assume it might be nice as a template, that is then edited, plus obviously double-checked, before committed.
The answer above has surely added more useful information to me personally, than any of the documented info did before. So I definitely see some value in it, although I am well aware, that we can’t let them write all the docu unchecked. Hence, the tongue-showing smiley