It is well known that the ruby comments are used to leave notes or micro-docs within the code and is ignored by the Ruby Interpreter. But can we do other things with comments?

There are several other functions that comments can offer. In this article, we shall dive into some of the use cases of comments that can have certain desirable impacts on the Ruby interpreter. Each use case has been explained in detail making it easier for even beginners to understand.


Shebang Comments

Shebang is a “comment” that indicates the interpreter directive for the interpreter to be used when the file is run as an executable in *nix operating systems. This specific comment is not unique to Ruby. Many scripting languages make use of the shebang to make scripts executable in a simple manner.

in addition to specifying the interpreter directive, you can also specify the flags like — jit or -w which will automatically be passed on to the interpreter when the executable is run. Let’s take a look at how this can be done:

#magic-comments #ruby #frozen-string-literals #comment #encoding

All You Need To Know About Comments in Ruby
1.60 GEEK