-
Notifications
You must be signed in to change notification settings - Fork 8
2016 08 09 cbk
baekkyu cho edited this page Aug 8, 2016
·
16 revisions
<요약>
- 꼬리재귀함수를 이용하여 loop를 작성하는 방법
- 고차함수 소개
- 다형적 고차함수의 예
- 기본적인 예제 하나
// 주석
/* 주석 */
/** 주석 */
object MyModule { //object 키워드는 singleton 형식을 만든다. (java의 static과 비슷)
def abs(n: Int): Int =
if (n < 0) -n
else n
private def formatAbs(x: Int) = {
val msg = "The absolute value of %d is %d"
msg.format(x, abs(x))
}
def main(args: Array[String]): Unit = //Unit은 java, c의 void와 같은 목적
println(formatAbs(-42))
}