george.gu 发表于 2013-2-1 12:00:44

Beanshell: how and where to use beanshell

 
How to use beanshell
beanshell Manual:
http://www.beanshell.org/manual/bshmanual.html
 
"loosely typed" variables

You can simply omit the types of variables that you use (both primitives and objects).
Beanshell automatically converts them to properly type before execute any operations. BeanShell will only signal an error if you attempt to misuse the actual type of the variable.
Demo 1: loosely typed method signature

take one method for an example:
add(a, b) {
return a + b;
}
 
Interpreter bsh = new Interpreter();
 
bsh.eval("print(add(1,2))"); 
bsh.eval("print(add(\"Oh \",\"baby\"))"); 
页: [1]
查看完整版本: Beanshell: how and where to use beanshell