fork download
  1. | a b stdout |
  2. stdout := FileStream stdout.
  3. FileStream stdin
  4. linesDo: [ :line |
  5. line isEmpty ifFalse: [
  6. (a isNil)
  7. ifTrue: [ a := line asNumber ]
  8. ifFalse: [ b := line asNumber ]
  9. ]
  10. ].
  11. stdout nextPutAll: '和: '; nextPutAll: (a + b) printString; nl;
  12. nextPutAll: '差: '; nextPutAll: (a - b) printString; nl;
  13. nextPutAll: '積: '; nextPutAll: (a * b) printString; nl.
  14. b = 0
  15. ifTrue: [
  16. stdout nextPutAll: 'ゼロで割ろうとしています'; nl
  17. ]
  18. ifFalse: [
  19. stdout nextPutAll: '商: '; nextPutAll: (a / b) printString; nl.
  20. nextPutAll: '余剰: '; nextPutAll: (a \\ b) printString; nl.
  21. ].
  22. stdout flush.
  23.  
Success #stdin #stdout #stderr 0.01s 9256KB
stdin
1,3
stdout
Object: nil和:  error: did not understand #generality
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #generality (SysExcept.st:1448)
SmallInteger>>+ (SmallInt.st:179)
UndefinedObject>>executeStatements (prog:11)
stderr
./prog:20: parse error, expected ']'