2
Main.rb is the only file I can run
eljayuu (1)

Hello there. Newbie here. I can't see to run anything other than main.rb when I have created multiple files. I select a different file and click run, nothing happens, any suggestions greatly appreciated.

You are viewing a single comment. View All
1
Zavexeon (202)

main.rb will always run first. You can, however, tell main.rb to load other ruby files. Some examples:

require 'filename' #do not include .rb extension
require_relative 'filename.rb' #include the extension, I'd suggest this over require
load 'filename.rb' #don't forget .rb

What they do:
require and require_relative load the specified files along with the file it is in, meaning that the files are running simultaneously.

load exits out of the current file and loads only the file specified. I'd suggest this if you're just trying to load only the content of a specific file.

Note: require often does not work in replit, so use require_relative instead.