Sunday, November 30, 2014

Ruby naming

Following along with the online LRTHW exercises and lesson 25. I copied the code as it was stated from the web page. Well, I typed it in manually rather than doing a copy and paste. Just to take a shortcut to type it in as fast as possible, I didn't capitalize the module name and I got the following error...

2.1.3 :001 > require "./ex25.rb"
SyntaxError: /home/.../ruby/ex25.rb:1: class/module name must be CONSTANT
from /home/.../.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/.../.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from (irb):1
from /home/.../.rvm/rubies/ruby-2.1.3/bin/irb:11:in `<main>'

After going back and capitalizing the module name, function names and references to the functions, I was able to get it run without error.

2.1.3 :001 > require "./ex25.rb"
 => true 

Found official documentation that discusses naming.  The exercise didn't cover the topic of naming...

http://www.ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html

No comments:

Post a Comment