Files
node/doc/api
Lance Ball ad8257fa5b repl: Assignment of _ allowed with warning
This commit addresses https://github.com/nodejs/node/issues/5431 by
changing the way that the repl handles assignment to the global _
variable.

Prior to this commit, node sets the result of the last expression
evaluated in the repl to `_`. This causes problems for users of
underscore, lodash and other packages where it is common to assign
`_` to the package, e.g. `_ = require('lodash');`.

Changes in this commit now result in the following behavior.

- If unassigned on the repl, `_` continues to refer to the last
  evaluated expression.
- If assigned, the default behavior of assigning `_` to the last
  evaluated expression is disabled, and `_` now references whatever
  value was explicitly set. A warning is issued on the repl -
  'expression assignment to _ now disabled'.
- If `_` is assigned multiple times, the warning is only displayed once.
- When `.clear` is executed in the repl, `_` continues to refer to its
  most recent value, whatever that is (this is per existing behavior).
  If `_` had been explicitly set prior to `.clear` it will not change
  again with the evaluation of the next expression.

PR-URL: https://github.com/nodejs/node/pull/5535
Fixes: https://github.com/nodejs/node/issues/5431
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-18 21:03:40 +01:00
..
2015-08-04 11:56:14 -07:00
2016-03-14 08:48:08 -07:00
2015-08-04 11:56:14 -07:00
2016-03-14 08:48:03 -07:00
2016-03-10 14:09:26 +01:00
2016-03-14 08:47:32 -07:00
2016-03-10 14:09:26 +01:00
2016-03-18 11:04:02 -05:00
2016-02-04 19:25:07 +01:00
2016-03-17 23:20:12 -04:00
2016-03-02 23:22:29 +01:00
2016-02-21 14:59:35 -05:00