On 2012-09-11, at 20:36, sergio_101 <
sergio.rrd@gmail.com> wrote:
yes, i know this sounds simple.. but is it possible to instantiate an
object with some parameters?
say i have a dictionary:
params := Dictionary new.
params at: 'sound' put: 'bark'
dog := Dog new.
^^ at this point, i would like to just create a dog and send it
'params' all at once..
can i do this? what would the syntax look like?
sure :) in Smalltalk (almost) everything is a message-send :)
So you can do the following:
dog := Dog sound: 'wuff'.
then a class side method:
Dog class >> #sound: aString
^ self basicNew
initializeWithSound: aString
;