高階函數
函數可以作為參數進行傳遞和返回值進行返回
//傳一個a乘b 就返回一個函數,邏輯是實現兩數相乘
//傳一個a*b 返回一個函數,邏輯是實現兩數相乘
//傳一個axb 返回一個函數,邏輯是實現兩數相乘
def funTest6(str:String,fun:(String)=Int):(Int,Int)=Int = {
val i: Int = fun(str)
i match {
異常處理
語法處理上和 Java 類似,但是又不盡相同。
java的異常處理
public class ExceptionDemo {
public static void main(String[] args) {
try {
int a = 10;
int b = 0;
int c = a / b;
}catch (ArithmeticException e){
// catch