Shadowing variables, which is effectively what you’ve done with 
“misspelt_argument”, is pretty-much always a bad idea in most languages.

In functional languages, it’s mostly impossible to do without the compiler 
complaining, and for very good reasons, one of which you’ve pointed out.

I suspect that tools like RuboCop would probably pick this sort of abomination 
up. Anyone know if that’s the case?



> On 13 Jan 2016, at 8:41 PM, Tom Hale <t...@hale.ee> wrote:
> 
> It took some debugging to come across this one:
> 
> irb(main):043:0> w
> NameError: undefined local variable or method `w' for main:Object
>       from (irb):43
>       from /home/ravi/.rbenv/versions/2.2.3/bin/irb:11:in `<main>'
> irb(main):044:0> w = w
> => nil
> irb(main):045:0>
> 
> Yeah, right, so what?
> 
> It leads to "find the nil" fun-hunts in cases such as:
> 
> irb(main):057:0> mispelt_argument = 
> Array(mispelt_argument).flatten.uniq.map(&:name)
> => []
> 
> Are there any cases in which this "feature" is actually useful, or is it an 
> unintended parser functionality?
> 
> Tom
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby or Rails Oceania" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rails-oceania+unsubscr...@googlegroups.com.
> To post to this group, send email to rails-oceania@googlegroups.com.
> Visit this group at https://groups.google.com/group/rails-oceania.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rails-oceania+unsubscr...@googlegroups.com.
To post to this group, send email to rails-oceania@googlegroups.com.
Visit this group at https://groups.google.com/group/rails-oceania.
For more options, visit https://groups.google.com/d/optout.

Reply via email to