December 2014
Intermediate to advanced
164 pages
2h 14m
English
CHAPTER 10
![]()
Functions and Methods
We have learned a lot about the Ruby programming language itself in the previous chapters along with its syntax and type characteristics. In this chapter we begin to look at “reusable code,” the ability to write a snippet of code that can be used multiple times during our application. This is sometimes known as the D.R.Y. (Don’t Repeat Yourself) principle.
Technically, because Ruby is a fully object-oriented language, Ruby’s functions are actually all methods, as they are all linked to objects.
Defining and Calling Methods
To call our Hello World multiple times, we will write a simple method named hello, and will ...
Read now
Unlock full access