Nikolai Weibull
2/27/2005 12:01:00 AM
* Sam Roberts (Feb 27, 2005 00:50):
> class Foo
> attr_writer :opt
> def initialize
> yield self
>
> # doesn't work
> remove_method 'opt='
>
> # doesn't work
> class < self
> remove_method 'opt='
> end
>
> # there must be a way?????
> end
> end
>
> f = Foo.new { |s| s.opt = 4 }
>
> # I want this to fail!
> f.opt = 1
> This has to be possible... whats the magic? Should I use
> #method_missing, so I can decide to respond to it only during
> initialization?
class Foo
attr_writer :opt
def initialize
yield self
undef :opt=
end
end
nikolai
--
::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}