Skip to content

Instantly share code, notes, and snippets.

@pasberth
Created December 12, 2011 03:37
Show Gist options
  • Select an option

  • Save pasberth/1464656 to your computer and use it in GitHub Desktop.

Select an option

Save pasberth/1464656 to your computer and use it in GitHub Desktop.
ごく一般的なRubyによるhello world
# puts "hello world"
# 表のrubyで伝承されるhello worldは↑になる
# しかし裏のrubyで秘伝されるhello worldはこうなるッッッ!!
Object.new.instance_eval do
define_singleton_method :to_s do "hello world" end
Module.new do
define_singleton_method :extended do |sub|
puts sub
end
end.tap { |it| extend it }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment