Project

General

Profile

Backport #5807 ยป bad.rb

An example where things don't work. - silvioricardoc (Silvio Cordeiro), 12/26/2011 03:28 AM

 
1
#! /usr/bin/ruby -w
2

    
3
def foo1
4
  puts "foo1 called"
5
end
6

    
7
class << self
8
  define_method(:foo2) do
9
    puts "foo2 called"
10
  end
11
end
12

    
13

    
14
def call_foos
15
  foo1
16
  foo2
17
end
18

    
19
class Bad
20
  def initialize
21
    call_foos
22
  end
23
end
24

    
25

    
26
call_foos  # calls foo1, foo2
27
Bad.new    # calls foo1, foo2