Boo 언어의 구문은 Python 언어의 그것과 매우 닮았다.

       def functionName(parameter1  as 타입1, ... , parameterN  as 타입N):
             block

이다.

또 Boo 언어의 반복문 양식은 Python  언어 처럼

       for varName in Range:
             block

이다.

또 Boo 언어의 print 문은 Python  언어의 것과 Groovy 언의의 것을 섞어 놓은 듯하다.
즉, Python 언어의 print 문 처럼 새줄 문자(\n)를 출력하며, Groovy 언어의 print 문처럼 GString을 스트링으로 변환하여 출력한다.


소스 파일명: forTest.boo
------------------------------[소스 시작]
def printDan(dan as int):
  for i in range(1, 10):
    print "${dan} x ${i} = ${dan*i}"

printDan(2)
------------------------------[소스 끝]

실행> booi forTest.boo
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18



컴파일 후 실행하기

컴파일> booc forTest.boo
실행> forTest
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18




크리에이티브 커먼즈 라이선스
Creative Commons License


Posted by Scripter
,