Exercise 25. Even More Practice


We’re going to do some more practice involving functions and variables to make sure you know them well. This exercise should be straightforward for you to type in, break down, and understand.

However, this exercise is a little different. You won’t be running it. Instead, you will import it into Ruby and run the functions yourself.


 1    module Ex25  2  3      # This function will break up words for us.  4      def Ex25.break_words(stuff)  5        words = stuff.split(' ')  6        return words  7      end  8  9      # Sorts the words. 10      def Ex25.sort_words(words) 11         ...

Get Learn Ruby the Hard Way: A Simple and Idiomatic Introduction to the Imaginative World of Computational Thinking with Code, Third Edition, Video Enhanced Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.