Squeak

 

Storing objects to a file

Page history last edited by Dave 3 yrs ago

#printString (implemented by #printOn:) creates a human-readable

description of your object. #storeString (or, more precisely,

#storeOn:) is a machine-parsable serialization of your object.

"Storing" writes out code that recreates the object when later read

back in (using #readFrom:). So a test for correctness of storing

would mean to compare the original and the read-back object.

 

In the case of literal objects, both representations are usually

equivalent. But try this:

 

a := {1. 2@3. #four}.

a storeString -> a printString

 

which gives

 

'(Array with: 1 with: 2@3 with: #four)' -> '#(1 2@3 #four)'

 

Only the storeString can be correctly read back in

 

Object readFrom: a storeString

Comments (0)

You don't have permission to comment on this page.