#first program
#function defination
def say_goodnight(name)
  result = "Good night, #{name}"
  return result
end

#function invoke
puts say_goodnight('Pa')

#capitalize method
def say_goodnight(name)
  result = "Good night, #{name.capitalize}"
  return result
end

puts say_goodnight('pa')

#Ruby uses a convention to help it distinguish the usage of a name:the first characters of a name indicate how the name is used.
#Local variables,method parameters,and method names should all start with a lowercase letter or with an underscore.
#Global variables are prefixed with a dollar sign($),and instance variables begin with an "at" sign(@).
#Class variables start with two "at" signs(@@).
#Finally,class names,module names,and constants must start with an uppercase letter.

posted on 2008-02-07 18:06  IT Person  阅读(186)  评论(0)    收藏  举报