Hi --

On Fri, 29 Aug 2008, John Pritchard-williams wrote:

> Again...just wondering....(and you can probably tell I'm comparing Ruby
> with Java/C here again, following on from the "++" discussion...)
>
> def MyObject
>  def my_method(obj)
>    if obj.class!=String then raise "Wrong Type!"
>    end
>    ...stuff...
> end
> end
>
> Would it cause problems with the general syntax to include some sugar to
> rewrite this as:
>
> ...
> def my_method(String obj)
> end
> ...
>
> Or is there any quick easy meta-programming to label methods as
> expecting certain types?
>
> Or am I being a big-baby wanting this kind of check, and I should get on
> with the Dynamic Vibe of Ruby ? :)
>
> (I just noticed that sometimes I get lost in my own programs by not
> checking types thoroughly; yet Java would have forced me to stop and
> think...)

I hate to sound curmudgeonly but please check out the probably
(literally) 2500 posts about this and related questions from the past.
It's been discussed and explained mind-numbingly many times.


David

-- 
Rails training from David A. Black and Ruby Power and Light:
   Intro to Ruby on Rails  January 12-15   Fort Lauderdale, FL
   Advancing with Rails    January 19-22   Fort Lauderdale, FL *
   * Co-taught with Patrick Ewing!
See http://www.rubypal.com for details and updates!