saving / loading simple objects

ODA Tomohiro tomohiro at sra.co.jp
Tue Mar 20 03:42:37 UTC 2001


Hi Eric,

As Bob says, your second example looks fine.

If you mind to store an object into a binary file, you restore a
storeOn:'ed object by Object class>>readFrom:.

 | stream |
 stream _ (FileStream fileNamed: 'simple.st').
 [allComments _ Object readFrom: stream] ensure: [inFile close].
 ^allComments

Or, you can just evaluate a storeOn:'ed stream instead of its entire
content string like:

 | stream |
 stream _ (FileStream fileNamed: 'simple.st').
 [allComments _ Compiler evaluate: stream] ensure: [inFile close].
 ^allComments
---
tomo





More information about the Squeak-dev mailing list