File: eachdemo.rb

Project: Invitation to Ruby

#!/usr/bin/env ruby

class CharEach
  def initialize(str)
    @str = str
  end

  def each(&block)
    @str.each_byte(&block)
  end

  def missing_method(sym, *args, &block)
    @str.send(sym, *args, &block)
  end
end

"Hello, World".each { |by| puts by }
CharEach.new("Hellow, World").each { |by| puts by }


[ Index ][ Table of Contents ]
Generated by [ source2html ]