函数 实例1:输入雇员的姓名,返回该雇员的年薪 create function fun1(spName varchar2) ,); begin +nvl(comm,) into yearSal from emp where ename=spName; return yearSal; end; / 在sqlplus中调用函数 var income number call annual_incomec('SCOTT') into: income; print income 同样我们可以在java程序…
定义函数 fun sum(a: Int, b: Int): Int { return a + b } 该函数中两个参数的类型都是Int,返回类型是Int 也可以做如下简化 fun sum(a: Int, b: Int) = a + b 将表达式作为函数体.返回值类型自动推断 当函数没有返回值时,返回类型是Unit fun printInt(i: Int): Unit { println("The value of i is $i.") } Unit可以省略 定义变量 定义只读局部变量使…