On Fri, Mar 19, 2004 at 08:39:31AM +0900, Simon Strandgaard wrote:
> On Fri, 19 Mar 2004 08:25:45 +0900, Bill Kelly wrote:
> > From: "David A. Black" <dblack / wobblini.net>
> > [...]
> >> Kernel.spleen("foo")
> > 
> > Here's what I'm getting:
> > 
> > $ cat test.rb
> [snip]
> 
> It seems difficult to invoke.. I tried this..
> but somehow a symbol is expected ?

Yup:

public :m

Here's some samples:

	def foo
		puts "outer"
	end

	class Bar
		def foo
			"inner"
		end
	end

	Bar.new.foo # => "inner"
	foo # => "outer"

	class Bar
		def foo
			super
		end
	end

	Bar.new.foo # => "inner"

Notice that Bar -inherits- foo. When you make an "outer" method, you're
actually adding it as a private that's part of Object. That's why 
		public :foo
at the top level works the way it does.


> 
> 
> server> ruby a.rb
> "foo"
> a.rb:4:in `public': nil is not a symbol (TypeError)
>         from a.rb:4
> server> expand -t2 a.rb
> def m
>   p "foo"
> end
> public m
> class C
>   def m(scope)
>     eval("m", scope)
>   end
> end
> C.m(binding)
> server>
> 
> --
> Simon Strandgaard
>