소스 파일명: testIf.io
- # Filename: testIf.io
- #
- # Purpose: Example using the conditional control structure syntax
- # if .... else ...
- # Execute: io testIf.io [number]
- printUsing := method(
- writeln("Using: io testIf.io [number]");
- writeln("This determines whether the number is positive or not.")
- )
- if (args size < 2) then (
- printUsing
- exit(1)
- )
- val := args at(1) asNumber
- if (val > 0.0) then (
- "#{val} is a positive number." interpolate println
- elseif (val < 0.0) then (
- "#{val} is a negative number." interpolate println
- ) else (
- "#{val} is zero." interpolate println
- )
실행> 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.
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
'프로그래밍 > Io' 카테고리의 다른 글
조립제법(Horner의 방법) 예제 for Io (0) | 2008.04.07 |
---|---|
80컬럼 컨솔에 19단표 출력하기 예제 for Io (0) | 2008.04.07 |
(최대공약수 구하기) while ... 반복문 예제 for Io (0) | 2008.04.06 |
구구단 출력 예제 for Io (0) | 2008.04.06 |
Hello 예제 for Io (0) | 2008.04.06 |