--- Begin Message ---Hello, My solution to day2 part1 is right this :processData: instructions| opcode index firstNumber secondNumber placeToPut firstNumberIndex secondNumberIndex |index := 1. opcode := instructions at: index. [ opcode ~= 99 ] whileTrue: [ firstNumberIndex := instructions at: index + 1. secondNumberIndex := instructions at: index + 2. firstNumber := instructions at: firstNumberIndex + 1. secondNumber := instructions at: secondNumberIndex + 1. placeToPut := (instructions at: index + 3) + 1. opcode == 1ifTrue: [ instructions at: placeToPut put: firstNumber + secondNumber ].opcode == 2ifTrue: [ instructions at: placeToPut put: firstNumber * secondNumber ].index := index + 4. opcode := instructions at: index ]. ^ instructions at: 1 so its ugly codeis there a way I can this more the smalltalk way by using streams or something else. if so, is there someone who can tell me or can let me see how to make this cleaner codeRoelof
--- End Message ---
[Pharo-users] how can I this refractor this so its more smalltalk
Roelof Wobben via Pharo-users Tue, 17 Dec 2019 07:01:18 -0800
- [Pharo-users] how can I this refractor this... Roelof Wobben via Pharo-users
- Re: [Pharo-users] how can I this refra... Kasper Osterbye
- Re: [Pharo-users] how can I this r... Roelof Wobben via Pharo-users
- Re: [Pharo-users] how can I this refra... Todd Blanchard via Pharo-users
- Re: [Pharo-users] how can I this refra... Ben Coman