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.
Singleton Class当我运行以下代码时,我没有看到该消息。这是为什么 ?
Singleton Class
ob = Object.new class << ob def func "Singleton class" end end ob.func
该方法返回一个字符串。要显示它,您必须使用puts.
puts
如果您在其中运行它,irb您将获得显示的结果字符串,因为在该模式下,每个返回值都会自动打印。
irb