摘要: Spell,也称pattern,idiom # Around Alias:从一个重新定义的方法中调用原始的,被重命名的版本。 # old_reverse是未改变的原始方法,reverse/new_reverse是改变的方法。 class String def new_reverse "x:#{old 阅读全文
posted @ 2018-03-18 18:00 Mr-chen 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 关于namespace,双冒号::的用法。 防止引用多个模块在一个文件/类中,有重名的对象。::可以调用类的类方法,和常量。 class Foo BAR = "hello" def self.hello puts "world" end end p Foo::BAR ✅ Foo::hello ✅ 根 阅读全文
posted @ 2018-03-18 09:33 Mr-chen 阅读(169) 评论(0) 推荐(0) 编辑