Crystal multi line comment
Asked Answered
K

2

7

Are there any multi line comments in Crystal ? Such as Ruby does :

=begin
    this is a
    multiline
    comment in Ruby
=end

This will simply give me an error in Crystal :

unexpected token: =

Katheykathi answered 6/10, 2017 at 22:43 Comment(0)
L
6

Crystal doesn't have multi-line comments. Simply prefix the block of lines you want to comment out with # single-line comments. Your editor should be able to do this for you.

Lenlena answered 6/10, 2017 at 23:14 Comment(5)
Seriously? No multi line comments? Doesn't sounds like something the creators would simply leave out...Desireedesiri
We left it out because all modern editors have a "comment block" feature to place a # at the start of the line—so just use that. Even vim has :s/^/# /, which operates on the selected block in visual line mode.Lenlena
Thanks, actually I do use Vim and the option for commenting out blocks is not that straightforward. Thanks for answering anyway, appreciated!Desireedesiri
@Lenlena I think "=begin/=end" would still be useful, much faster than doing the :s/^/# /, trick in vimPonzo
I presume this precludes embedded comments as wellDost
S
-1

Crystal allows multi-line comments by highlighting multiple lines and then using the shortcut Alt+M

Simpleminded answered 25/7, 2022 at 21:8 Comment(1)
That would be your IDE that does that, not the language. The IDE is the tool that allows you to edit the code in an efficient way, it is the IDE that has the shortcuts. The language does not possess any shortcuts itself unless you built a program that is reacting to them but the source code still would not.Katheykathi

© 2022 - 2024 — McMap. All rights reserved.