четверг, 22 мая 2008 г.

using modules

module Sim
  def puts(str)
    Kernel.puts "hello #{str}"
  end
end

puts('world') # Kernel::puts here
begin
  Sim.puts('world') # private method called
rescue
  puts $!
end

include Sim # don't want _include_ them all, just use them

puts('world') # I want Kernel::puts here!!!
Sim.puts('world') # just right

# ???

Комментариев нет: