摘要:
def add_method(c, m, &b) c.instance_eval { #在此使用class_eval是一样的效果 define_method(m, &b) }end add_method(String, :greet) { "Hello, " + self } p "world".greet # => "Hello, world" 阅读全文
摘要:
class Generator def initialize(enumerable) @enumerable = enumerable # Remember the enumerable object create_fiber # Create a fiber to enumerate it end def next ... 阅读全文