Ruby On Rails Lesson
This concludes our overview of the Ruby language. In Chapter 5, we’ll start putting it to good use in developing the sample application.
We won’t be using the example_user.rb file from Section 4.4.5, so I suggest removing it:
Then commit the other changes to the main source code repository:
1. By replacing the question marks in Listing 4.10 with the appropriate methods, combine split, shuffle, and join to write a function that shuffles the letters in a given string.
2. Using Listing 4.11 as a guide, add a shuffle method to the String class.
3. Create three hashes called person1, person2, and person3, with first and last names underthe keys :first and :last.Then create a params hash so that params
[:father] is person1, params[:mother] is person2, and params[:child] is person3. Verify that, for example, params[:father][:first] has the right value.
4. Find an online version of the Ruby API and read about the Hash method merge.
5. Find and follow the Ruby Koans to reach Ruby enlightenment.
Listing 4.10 Skeleton for a string shuffle function.
Listing 4.11 Skeleton for a shuffle method attached to the String class.