As far as I understand it: """ is used for documentation of methods, macros etc.
Therefore using """ as I did should be bad practice Anyway I don’t really get why it produces an error.
julia> myvar = """
hello
my friend
"""
"hello\nmy friend\n"
so its not a comment. Writing a string (multiline or not) before a function definition tells julia that this string is the documentation for this function
julia> "This is foo" foo(x) = x^2
foo
help?> foo
search: floor pointer_from_objref OverflowError RoundFromZero FileMonitor functionloc StackOverflowError @functionloc Factorization OutOfMemoryError
This is foo
So my point is that, no, it is not a comment. do not use strings to write comments.
Slightly off-topic, but I have been thinking about this and related issues in light of recent questions.
When learning a new computer language, my expectation is that I need to read about 200–300 pages of documentation (hopefully a single document, but it might be all over the place). I usually just skim through some parts that I am not immediately interested in, but it is good to know about concepts that exist in the language and I can go back to them. This takes me a couple of days (I work through examples), but prevents a lot of confusion later on.
The current manual (without stdlib and devdocs) is about 120K words, roughly 200 pages with 600 words/page (lower range for textbooks and manuals, some go higher). If many people who read this are still confused about something, then the documentation clearly needs to be improved, or possibly the syntax/semantics need to be redesigned. However, my expectation is that confusion which arises before reading the documentation is an issue that needs to be remedied by the user, not the developers or the authors of the docs.
As a Julia-by-the-manual user at the moment: a search for “comment” in the online Julia manual gave no heading or section in the results that even mentions comment syntax. If it is there, it is poorly discoverable (at least by me).
In addition, there doesn’t appear to be a section on the Julia language syntax. This is where I usually look to find information on comments.
If you search comment, then one of the sections suggested is the Punctuation section, which does tell you how to do multiline comments. Although it doesn’t tell you how to do multiline strings, which is possibly an omission?