Hi
Is the => an operator?
for example in
rescue ArgumentError => e
Looks like a hash, but without {} ...
What does it do (in general)?
thanks
Opti
Hi
Is the => an operator?
for example in
rescue ArgumentError => e
Looks like a hash, but without {} ...
What does it do (in general)?
thanks
Opti
Is the => an operator?
for example in
rescue ArgumentError => eLooks like a hash, but without {} ...
What does it do (in general)?
It *is* a Hash. This is one of the nicest bits of syntactic sugar in Ruby (if you happen to like Syntactic sugar...)
* If you want to pass a hash as the last (or the only) parameter to a method, you can omit the {} braces.
* Methods don't need () brackets around their parameters unless operator precedence requires it.
Simple, but rather lovely for those of us that find mentally parsing ((([{)}]) to be headache inducing; I could never be a LISP coder...
Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>
> Is the => an operator?
> for example in
> rescue ArgumentError => e
>
> Looks like a hash, but without {} ...
> What does it do (in general)?It *is* a Hash.
I wouldn't jump to that conclusion in this specific case. If it were a
hash, e would have to already be defined.
This is one of the nicest bits of syntactic sugar in Ruby (if you happen
to like Syntactic sugar...)
On Thu, Jan 26, 2017 at 2:22 AM, Andy Jones <Andy.Jones@jameshall.co.uk> wrote:
* If you want to pass a hash as the last (or the only) parameter to a
method, you can omit the {} braces.* Methods don't need () brackets around their parameters unless operator
precedence requires it.Simple, but rather lovely for those of us that find mentally parsing
((([{)}]) to be headache inducing; I could never be a LISP coder...
I wouldn't jump to that conclusion in this specific case. If it were a hash, e would have to already be defined.
Point.
Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>