On Tue, Oct 01, 2002 at 10:39:55PM +0900, William Djaja Tjokroaminata wrote:
> I usually code
> 
>     def func (a)
>         raise "type error" unless a.kind_of? Fixnum
>         ....
> 
> Now, I just want a convenience in writing the above code if I can just
> write
> 
>     def func (Fixnum a)
>         ....
> 
> In this case, that's it.  The new code is not more safe than the code that
> we can write right now with Ruby.  It is just more convenient, I
> guess...

William, what about this?

def func (a)
  a.is_a?(Fixnum) or raise "type error"

As someone that is reading someone else's source, that is what I'd be
grateful for.  It's almost plain English and makes your intent very
clear.


Massimiliano