Error when opening Ruby File (Beginner) + How to run a file?

Damien Robichaud

When I try to open A ruby file in the same directory something weird happens, like so :

C:\RubyFiles>file = File.open("Lottery.rb", "r") 'file' is not recognized as an internal or external command, operable program or batch file.

now I know this has nothing to do with the opening of the file itself, but I wanted to have an example ;)

(This has been resolved^) :D

But now I would like to know how to run the file itself? Can anyone help? Thanks in advance!

Cameron Martin

After opening irb, you can execute a ruby file using Kernel#load

load 'Lottery.rb'

If this file just includes module/class definitions, you probably only want to load it once. This is what Kernel#require ensures:

require 'Lottery.rb'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Error when opening saved file

From Dev

Encoding error when opening an Excel file with xlrd

From Dev

Emacs polymode gives error when opening file

From Dev

Error when opening file for reading in c#

From Dev

XML file to Excel, error when opening

From Dev

phpexcel Fatel Error when opening file

From Dev

Cryptic error in lxml when opening file

From Dev

Memory error when opening the file with read()

From Dev

Libgdx: File not found error 'Internal' when opening external file

From Dev

Libgdx: File not found error 'Internal' when opening external file

From Dev

How to determine file in "Error opening file for reading" error

From Dev

SQLiteManager: Error in opening file?

From Dev

Error handling in file opening

From Dev

Opening a file with a name error

From Dev

PHP file opening error

From Dev

PHP file opening error

From Dev

Error, opening json file

From Dev

Run-time error upon opening excel file

From Dev

Run-time error '1004' while opening Word File

From Dev

TsLint ignore files or don't run when opening file

From Dev

Macro does not run when opening a File/Workbook from within Excel

From Dev

How come I get a doctest error when I run this file?

From Dev

Run .sh file instead of opening it

From Dev

Run process before opening file

From Dev

How to share file delete privilege when I opening a file by ifstream

From Dev

How to get rid of the warnings when opening a file that has a .swp file?

From Dev

Run a script on a file before opening a file in vim

From Dev

Error kernel_require.rb:55:in `require': cannot load such file when trying to run ruby program

From Dev

how to run migration file with ruby script

Related Related

HotTag

Archive