ruby命名规范

文件、变量、方法:使用snake_case

hello_ruby.rb

student_id = 10001 def loud_talk puts "I am a student!" end

类、模块:使用CamelCase

module OneModule
    ...
end

class MyClass
    ...
end

常量:大写、snake_case

PI = 3.1415
MY_ID = 10001

方法:

表示判断方法名后加问号?

def who_is_older?
        ...
end

可能会造成潜在危险的方法加!

def update!
     ...
end
原文地址:https://www.cnblogs.com/stellar/p/5687210.html