def say_goodnight(name) result ="Good night ." +name return result end def say_goodmorning(name) result ="Good morning .#{name}" return result end def say_goodafternoon(name) result ="Good afternoon .#{name}" end puts say_goodnight("jake") puts say_goodmorning("heidsoft") puts say_goodafternoon("heidcloud")
局部变量、方法参数和方法名称都必须以小写字母和下划线开始
全局变量,以($)为前缀
实例变量,以(@)符号开始
类变量,以(@@)两个@符号开始
类名称、模块名称和常量都必须以一个大写字母开始
ruby 变量和方法
时间: 2024-10-14 21:38:15