puts "#ruby30th" end end Foo.new.foo # => #ruby30th Bar = Class.new do de fi ne_method(:bar) do stdout = IO.new(2) stdout.send(:write, “#ruby30th\n”) end end Bar.new.bar # => #ruby30th
r u b y 3 0 t h) def foo(chars, &block) yield chars foo(&block) end foo(chars) { |chars| print chars[i]; i += 1; break if i >= chars.length } puts “\n” # => #ruby30th