Hi sergio what do you want to do? Object subclass: #MyClass instanceVarNames: 'dict' MyClass>>initialize [ super initialize. dict := Dictionary new. ] MyClass>>atKey: aKey put: aVal [ dict at: aKey put: aVal ] MyClass>>atKey: aKey [ ^ dict at: aKey ] let you manage the key/val that you want? Let me know if this answers your question. Stef On 22/5/14 19:37, sergio_101 wrote:
is it possible to initialize a class with a dictionary? my first thought would be to create a method like:
intializeWithDictionary: aDictionary
then, loop through the elements and do something like:
instVarNamed: key put: value
but the book says:
Caveat: Although these methods are useful for building development tools, using them to develop conventional applications is a bad idea: these reflective methods break the encapsulation boundary of your objects and can there- fore make your code much harder to understand and maintain.--
should i avoid this?
---- peace, sergio photographer, journalist, visionary #BitMessage BM-2D8VWUJSS41RFKh1ec83preVabHrnniExa
http://www.Village-Buzz.com http://www.ThoseOptimizeGuys.com http://www.CodingForHire.com http://www.coffee-black.com http://www.painlessfrugality.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101