F
F
fapchat2019-06-05 12:46:27
ruby
fapchat, 2019-06-05 12:46:27

Why is the ruby ​​file.rb construct needed?

On the Internet and in books, they say that in order to call a ruby ​​file from the command line, you need to write

ruby (filename).rb

BUT, as I noticed a long time ago, you can just write the name of the file, without the word 'hack' and .rb
The whole world is doing wasting extra time on this, or am I just not understanding something?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TyzhSysAdmin, 2019-06-05
@fapchat

Automatic detection of an interpreter, etc. this, of course, greatly simplifies life, but this is applicable only on the developer's machine, this method should not be used when deploying the application.
So if you develop locally, do whatever you want if you started writing bash scripts, ansible, chief, etc. then there you use the full construction with an explicit indication of the interpreter, otherwise the people to whom you provide the application will also have to configure the environment for you.
In general, this is syntactic sugar and, as always, it must be applied carefully and thoughtfully.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question