Um programa Ruby pode ser armazenado em um arquivo? Como executá-lo?

Compartilhe esta Faq!

Um programa Ruby pode ser armazenado em um arquivo? Como executá-lo?

Sim. Para executá-lo, veja:

Unix:

% cat > test.rb
print "hello world\n"
^D
% cat test.rb
print "hello world\n"
% ruby test.rb
hello world

Dos:

C:\ruby> copy con: test.rb
print "hello world\n"
^Z
C:\ruby> type test.rb
print "hello world\n"
C:\ruby> ruby test.rb
hello world



Faqs relacionadas