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.

ex25.rb

 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        return words.sort 12      end 13 14      # Prints the first word after shifting it off. 15       ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.