From: MonkeeSage Date: 2007-12-10T20:10:03+09:00 Subject: Re: How much would variable declarations in Ruby make you wince? On Dec 8, 6:51 pm, "Just Another Victim of the Ambient Morality" 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. 1.) How does predeclaration help? var l = [1,2,3] var h = {:a=>"b"} wants_an_array(h) # => error 2.) While that may alleviate the typo problem, it introduces another class of bugs which are just as subtle: var list = create_useful_list if should_modify_list(list) # I meant to modify the variable "list" here... var list = modify_list(list) end use_list(list) Once one became accustomed to typing "var", there is every chance that it would be used places where a pre-existing variable was meant, but the "var" just got typed out of habit. Regards, Jordan