--f46d04479f93779a3604b697c92e
Content-Type: text/plain; charset=UTF-8

On Sun, Jan 15, 2012 at 20:42, Ralph Shnelvar <ralphs / dos32.com> wrote:

>  rescue MySpecialError ex
>
> Does the
>  > have anything to do with hashes or is this syntax reserved for rescue
> clauses?
>

It's a fair question, since the " is shared between the two. However, if
this syntax were actually a hash, it would be getting passed to rescue() as
a method, but ex would be seen as a local variable. Explicitly:

begin
  raise StandardError
rescue({StandardError e})
  p e
end

# NameError: undefined local variable or method `e' for main:Object

or

begin
  raise StandardError
rescue(StandardError e)
  p e
end

# SyntaxError: (irb):8: syntax error, unexpected tASSOC, expecting ')'
# rescue(StandardError e)

--f46d04479f93779a3604b697c92e--