자바 배경에서 오는 스칼라를 배우려고합니다. 아래 프로그램을 실행해야합니까? Functional
파일을 마우스 오른쪽 버튼으로 클릭하면 파일을 실행하는 옵션이 표시되지 않습니다. Timer.run
메서드를 실행하려면 무엇을 변경해야합니까? Eclipse3.7 & Scala 플러그인 2.0.2를 사용하고 있습니다.개체에서 메서드를 실행하는 방법 - 초보자
class Functional {
object Timer {
def oncePerSecond(callback:() => Unit) {
while (true) { callback(); Thread sleep 1000 }
}
def timeFlies() {
println("time flies like an arrow...")
}
def run() {
oncePerSecond(timeFlies)
}
}
def main(args: Array[String]) {
Timer.run();
}
}
@ om-nom-nom 예, 제 질문을 업데이트했습니다. –