I understand why a = a
in Ruby produces nil
(see Why is a = a
nil
in Ruby?).
But using the rightwards assignment operator, a => a
produces an error:
irb(main):001:0> a => a
(irb):1:in `<main>': undefined local variable or method `a' for main:Object (NameError)
But when the right hand side is not a complex pattern, I thought =>
should be exactly the same as =
, just flipped.
So why does a => a
not behave the same as a = a
?