P
Pokkai Dokkai
is there any idea to change public definition to private definition by
using alias or some others....
using alias or some others....
is there any idea to change public definition to private definition by
using alias or some others....
Gavin said:Slim2:~ phrogz$ ri private
hey please understand my question correctly
that is ,
change public definition(public method) to private definition(private
method) by
using some ideas....
i want like this (ofcourse below is wrong)
-------------------------------------------------
class Cls1
def view
puts "from view"
end
def self.pp
alias rivate view ublic view
end
end
c1=3DCls1.new
c1.view ----->from view
Cls1.pp
c1.view ----->undefined method `view' for #<Cls1:0xb7daa8b0>
(NoMethodError)
Morton said:I don't believe you can do what I think you want with 'alias'. Maybe
the following will work for you.
<code>
class Cls1
def view
puts "from view"
end
end
c1 = Cls1.new
c1.view
class Cls1
private :view
end
c1.view
</code>
<result>
from view
NoMethodError: private method �view� called for #<Cls1:0x80e10at top
level
in untitled document at line 14
</result>
Regards, Morton
Pokkai said:i thing freeze is used to protect modification for object.
like that what is used to protect modification for class ?
Morton said:On Dec 2, 2007, at 12:20 AM, Pokkai Dokkai wrote:
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.