Ruby Uninitialized Constant NameError for Class Name -


i want inherit sub-class parent-class.

here code. 3 classes created in 3 separate files.

class transportation #codes end  class plane < transportation #codes end  class boat < transportation #codes end 

and when running code, got error boat, no issue plane when have plane created:

uninitialized constant transportation (nameerror) 

can me issue?

thanks

there no reason code fail, unless definition of transportation in file.

if case, , these in different files, don't forget require file transportation class before other file usage in it.

as mentioned, there 3 different files.

you can create file has required libraries. perhaps in bin/transport_simulator.rb file.

require 'transportation' require 'boat' require 'plane' 

now required in proper order, , files classes subclass transportation know class.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -