Ruby error prompt:
Class/Module name must be constant
= Begin to comment
This is also comment
= End
Puts "nolonggercomments ";
# Rdoc rules
# = Headers
# This is header content
#== Sub Headers
# This is sub header content
#=== Sub Headers
# This is sub Headers
Class animal
# This is the comment for the 'new' method!
Def initialize type
@ Name = Type
End
# This is comment for 'shout' Method
# Second line
# * This is sub line 1
# * This is sub Line 2
Def shout
If @ name = 'Dog'
Puts "Wang! Wang! "
Elsif @ name = 'cat'
Puts "Miao! Miao! "
End
End
End
Dog = animal. New 'dog'
Dog. Shout
Gets
Ruby class names must be capitalized.
This involves a convention on Ruby interpreters.
::
1. Set the variables encoded in acsii and whose names start with uppercase as Constants by default.
2. The first letter of a local variable in ruby is in lower case.
3. the constructor name in ruby is initialize.
4. The leading @ character of the member variable (instance variable) in ruby, which is declared and initialized in initialize.
5. attributes in ruby are declared using attr_writer and attr_reader, which correspond to the set and get of C # respectively. attr_accessor is readable and writable.
6. The $ operator of the global variable in ruby.
7. constants (constants) in Ruby start with uppercase letters, and the conventions are all uppercase letters.
Solution:
Change the class name to animal.