Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JShell dollar variable name numbering

When I enter an expression in JShell (9.0.1) it comes back with:

$22 -> <value>

Where does the 22 come from and what's happened to $1 to $21? (They are undefined.)

I seem to vaguely remember (when I started with Java 9.0) that the variables started with $1, which made more sense. Now, with 9.0.1,they all start with $22. Why?

like image 957
DodgyCodeException Avatar asked Nov 30 '17 12:11

DodgyCodeException


1 Answers

They are there, just do a

/list

to find the list of all. They are there because you seem to have already consumed 1 to 21[21 snippets/statements] until you reached the $22 -> <value> snippet.

Trying to /reset and then adding snippet should set you back :-

jshell> 0+1
$1 ==> 1
like image 185
Naman Avatar answered Nov 19 '22 19:11

Naman