> On 8 Aug 2017, at 22:39 , Herby Vojčík <he...@mailbox.sk> wrote: > > Hello! > > I've got this portion in my delegate: > > requestPayload ifNotNil: [ uuidKeys do: [ :each | > requestPayload at: each ifPresent: [ :s | > requestPayload at: each put: (UUID fromString: s) ] ] ]. > responsePayload := self towergame clientSync: requestPayload. > responsePayload ifNotNil: [ uuidKeys do: [ :each | > responsePayload at: each ifPresent: [ :uuid | > responsePayload at: each put: uuid asString ] ] ]. > > Now I would gladly use something like Dictionary >> at:ifPresentTransform: > aBlock. But it is not present, so I have two choices: > > 1. Add it as extension method, but then it may clash if someone else has > similar idea. > 2. Add private helper TowergameDelegate >> dict:at:ifPresentTransform:, > which is longer and needs additional self receiver. > > Which is preferable? > > Herby
Following existing convention, an extension would be named #at:ifPresentPut: I wonder though, wouldn't it be simpler to just put(UUID fromString: s) in the first place, and convert (dict at: uuidKey) in the accesses that needs it (or vice versa)? Shifting the class of values like this seems like it could be a nightmare to debug and/or extend in the future remaining confident all uses will occur in the correct/expected order... Cheers, Henry
signature.asc
Description: Message signed with OpenPGP