Skip to content

Instantly share code, notes, and snippets.

@heartpunk
Created January 25, 2014 04:01
Show Gist options
  • Save heartpunk/8611653 to your computer and use it in GitHub Desktop.
Save heartpunk/8611653 to your computer and use it in GitHub Desktop.
+= is not equivalent to =+. This shows some about how.
2.0.0-p247 :005 > pp Ripper.lex('foo += 1');nil
[[[1, 0], :on_ident, "foo"],
[[1, 3], :on_sp, " "],
[[1, 4], :on_op, "+="],
[[1, 6], :on_sp, " "],
[[1, 7], :on_int, "1"]]
=> nil
2.0.0-p247 :006 > pp Ripper.lex('foo =+ 1');nil
[[[1, 0], :on_ident, "foo"],
[[1, 3], :on_sp, " "],
[[1, 4], :on_op, "="],
[[1, 5], :on_op, "+"], <== this is the unary + operator, which does nothing.
[[1, 6], :on_sp, " "],
[[1, 7], :on_int, "1"]]
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment