Runtime evaluation: Difference between revisions

New post showing the use of Java's REPL jshell. In addition to an existing post.
(Added FreeBasic)
(New post showing the use of Java's REPL jshell. In addition to an existing post.)
Line 805:
at Evaluator.eval(Evaluator.java:33)
at Evaluator.main(Evaluator.java:21)</pre>
 
===Java REPL===
Java has a REPL called jshell which can be used for runtime evaluation. It is started by entering the jshell command from the command line. Here is a typical session:
<pre>
C:\Program Files\JDK\bin> .\jshell
| Welcome to JShell -- Version 20
| For an introduction type: /help intro
 
jshell> double value = 12.0
value ==> 12.0
 
jshell> value * 3
$2 ==> 36.0
 
jshell> List<Integer> items = List.of( 1, 2, 3 )
items ==> [1, 2, 3]
 
jshell> for ( int item : items ) { System.out.print(item * item + " "); }
1 4 9
 
jshell> void helloWorld() { System.out.println("Hello World"); }
| created method helloWorld()
 
jshell> helloWorld()
Hello World
 
jshell> /exit
| Goodbye
</pre>
 
=={{header|JavaScript}}==
871

edits