Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这个问题是关于 Ruby 中的编程实践的。是否最好在静态方法中在 ruby 中创建实例变量?还是应该在initialize方法中创建它们?
initialize
那么初始化就是为此而做的,你为什么要做一些不同的事情。
class SomeClass def initialize(first, second) @first = first @second = second end end