From: Paul Brannan Date: 2001-12-11T01:44:49+09:00 Subject: [ruby-talk:28101] Re: Ensuring a specific type On Tue, Dec 11, 2001 at 01:39:46AM +0900, Fabian Senftenberg wrote: > Is there any way I can make sure that an expression (a block) is of a > specific type? Suppose, I have a fancy little class like the > following: > > class Interval > @start = Time.new() > @duration = 0 This is not correct. You should not initialize instance variables here. > def initialize(s, d = 0) > @start = s > @duration = d Instead, you should initialize them here. > end > > def end() > return #{@start + @duration}.usec > end > end Paul