프로그래밍/Io

if ... else ... 예제 for Io

Scripter 2008. 4. 6. 22:00

소스 파일명: testIf.io

  1. #   Filename: testIf.io
  2. #
  3. #   Purpose:  Example using the conditional control structure syntax
  4. #                 if .... else ...
  5. #   Execute: io testIf.io [number]
  6. printUsing := method(
  7.     writeln("Using: io testIf.io [number]");
  8.     writeln("This determines whether the number is positive or not.")
  9. )
  10. if (args size < 2) then (
  11.     printUsing
  12.     exit(1)
  13. )
  14. val := args at(1) asNumber
  15. if (val > 0.0) then (
  16.     "#{val} is a positive number." interpolate println
  17. elseif (val < 0.0) then (
  18.     "#{val} is a negative number." interpolate println
  19. ) else (
  20.     "#{val} is zero." interpolate println
  21. )



실행> io testIf.io
Using: io testIf.io [number]
This determines whether the number is positive or not.

실행> io testIf.io 1.234
1.234 is a positive number.

실행> io testIf.io 1.234
-1.234 is a negative number.

실행> io testIf.io 0
0 is zero.




Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.