33. Rewriting Expressions
In this exercise we ask you to rewrite some expressions or to understand the difference forms that a solution can take. Some of the expressions are explained in https://medium.com/concerning-pharo/elegant-pharo-code-bb590f0856d0
33.0.1. Exercise: Examine the block expressions
- What is the final result of sum?
- Rewrite this piece of code to use explicit array indexing (with the message
at: ) to access the array elements. Test your version.
- Rewrite this code using
inject:into: (Look at the implementation of
inject:into: and its users in the system to understand how to use it).
33.0.2. Exercise: Comparing expressions
You can express in different way the same computation. Have a look at each of them and check the messages that you do not know. Look for their implementation.