프로그래밍/Io
if ... else ... 예제 for Io
Scripter
2008. 4. 6. 22:00
소스 파일명: 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 대한민국 라이센스에 따라 이용하실 수 있습니다.