2007-03-29 Stephen Compall * kernel/Collection.st: Add and describe class from: protocol. * kernel/Array.st: Specialize from:. * kernel/Dictionary: Same. --- orig/kernel/Array.st +++ mod/kernel/Array.st @@ -46,6 +46,14 @@ and general access behavior from SequenceableCollection.' ! +!Array class methodsFor: 'instance creation'! + +from: anArray + "Answer anArray, which is expected to be an array specified with a + brace-syntax expression per my inherited protocol." + ^anArray +! ! + !Array methodsFor: 'printing'! printOn: aStream --- orig/kernel/Collection.st +++ mod/kernel/Collection.st @@ -51,6 +51,14 @@ !Collection class methodsFor: 'instance creation'! +from: anArray + "Convert anArray to an instance of the receiver. anArray is + structured such that the instance can be conveniently and fully + specified using brace-syntax, possibly by imposing some + additional structure on anArray." + ^self withAll: anArray +! + withAll: aCollection "Answer a collection whose elements are all those in aCollection" ^self new addAll: aCollection; yourself --- orig/kernel/Dictionary.st +++ mod/kernel/Dictionary.st @@ -49,6 +49,16 @@ !Dictionary class methodsFor: 'instance creation'! +from: anArray + "Answer a new dictionary created from the keys and values of + Associations in anArray, such as {1 -> 2. 3 -> 4}. anArray + should be specified using brace-syntax." + | inst | + inst := self new: anArray size. + anArray do: [:assoc | inst at: assoc key put: assoc value]. + ^inst +! + new "Create a new dictionary with a default size" "Builtins defines a #new method, so that during bootstrap there is a way