# 以名呼叫參數（By-name parameter）

``def sum(a: Int, b: Int) = a + bprintln(sum(1 + 2, 3 + 4))       // 顯示 10``

``def unless(cond: Boolean, func: () => Any) = {    if(!cond) {        func()    }}unless(false, () => println("XD"))unless(true, () => println("Orz"))``

unless(false, println("XD"))

``def unless(cond: Boolean, expr: => Any) = {    if(!cond) {        expr    }}unless(false, println("XD"))unless(true, println("Orz"))``

def unless(cond: Boolean, expr: => Any) = {
if(!cond) {
expr()   // 不能有括號
}
}

``def and(c1: Boolean, c2: => Boolean) = {    if(c1) c2 else c1}println(and(5 > 3, 10 > 3))  // trueprintln(and(5 > 3, 10 < 3))  // falseprintln(and(1 > 3, 10 > 3))  // false``

``def and(c1: Boolean, c2: => Boolean) = {    if(c1) c2 else c1}println(and(5 > 3, {print("run.. "); 10 > 3}))  // 顯示 run.. falseprintln(and(1 > 3, {print("run.. "); 10 > 3}))  // 顯示 false``

``def until(cond: => Boolean, expr: => Unit) {    if(!cond) {        expr        until(cond, expr)    }}var count = 10until(count == 0, {    println(count)    count -= 1})``