sergio_101 wrote
But I don't really know what were you using that dictionary for and what was the intention (#params: is not a very nice name).
i have been intentionally being vague about what i am doing, as i am trying to understand the best smalltalk practice, without introducing an approach from another language.
the idea i am after is something like this in rails..
i can make a hash like: dog_params = {:sound => 'bark', :food => 'steak'}
and create a dog like: Dog.create(dog_params)
and have a dog that with those params.. i just want to make sure i am not inventing a problem to solve.. and that there isn't a more 'smalltalky' way to do it.
There is no other way to do what you want except using a dictionary/collection/etc. They keywords in Smalltalk must preserve the order because they're part of the method name, not its arguments. You could build your own way of passing "dynamic" parameters to the constructor, but most of the times if you need too many arguments for a constructor you might be needing to introduce a new abstraction, so take it as a sign to reify something. Syntax sugar in Smalltalk most of the times comes from better abstractions, not from the language's syntax. Regards, -- Esteban. -- View this message in context: http://forum.world.st/smalltalk-instantiate-an-object-with-parameters-tp4647... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.