ruby - Why is kernel_required.rb in my stack trace? -
i forgot put word end, @ end of if statement, , got following error:
/home/***/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': **/home/****/desktop/ruby/food_finder/lib/restaurant.rb:84: syntax error, unexpected end-of-input, expecting keyword_end (syntaxerror)** /home/****/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require' /home/****/desktop/ruby/food_finder/lib/guide.rb:1:in `<top (required)>' /home/****/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require' /home/****/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require' init.rb:14:in `<main>'
my code without errors:
def self.saved_restaurants # read restaurant file restaurants = [] if file_usable? file = file.new(@@filepath, 'r') file.each_line |line| restaurants << restaurant.new.import_line(line.chomp) end file.close **end** -- > forgotten end # return instances of restaurant return restaurants end
my code errors:
def self.saved_restaurants # read restaurant file restaurants = [] if file_usable? file = file.new(@@filepath, 'r') file.each_line |line| restaurants << restaurant.new.import_line(line.chomp) end file.close -- > forgotten end # return instances of restaurant return restaurants end
my questions are: why errors has noting code? following:
/home/***/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require':
- what error mean?
when use correct syntax saved_restaurants method, don't error.
your file restaurant.rb
read method call require
in guide.rb
, defined in kernel_require.rb
. within method definition, has part:
def require path ... rescue loaderror => load_error ... raise load_error end
when have syntax error in file read, raise loaderror
, rescued, , raised error of require
.
Comments
Post a Comment