On Dec 12, 2007 4:21 AM, Roger Pack <rogerpack2005 / gmail.com> wrote:
> >     The two most popular sources of bugs for me when programming in Ruby
> > are:
> >
> > 1)  Passing the wrong object as a parameter to a method.
> > 2)  Accidentally creating a new variable.
>
> I agree with number 1.  I like duck typing and respect it, but I have
> seriously thought of suggesting 'voluntary' type checks to Ruby before,
> since it is a very common problem to pass a String instead of an
> Integer.
> I would have except I thought I might be bludgeoned by the community or
> something.  I still would use something like
> def func_1(a ==> String, b ==> Fixnum)
> end
> if I had it.  If only to ensure expected use at the beginning of coding
> creation.

Try out http://people.freebsd.org/~eivind/ruby/types/

It adds a fairly flexible syntax for doing these kinds of checks,
about as compact as the above.  You can find out if they are useful to
you or not.  (It also allows more appropriate type checks, like
respond_to?)

Eivind.