From: Paul Lutus Date: 2006-09-03T03:00:31+09:00 Subject: Re: Class behaviour Geoff Barnes wrote: > Just curious, can I write a class that can check values as they are > assigned to objects? Sure, just declare accessors in the usual way, then write your own methods to check the values: ------------------------------------ #!/usr/bin/ruby class Suspicious attr_accessor :a def a=(v) raise "Number Range Error" if v < 0 || v > 5 @a = v end end s = Suspicious.new s.a = 10 # number range error puts s.a # never gets here ------------------------------------ -- Paul Lutus http://www.arachnoid.com