File: safe_study.rb

package info (click to toggle)
ruby-facets 2.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,824 kB
  • sloc: ruby: 25,483; xml: 90; makefile: 20
file content (16 lines) | stat: -rw-r--r-- 221 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

  class X
    def yo=x; @yo=x; end
  end

  class Y
    def yo!; puts @yo; end
  end

  x = X.new

  class << x; Y.instance_methods.each {|m| define_method m, Y.instance_method(m)}; end 

  x.yo = "Hello World"
  x.yo!