
There are two types of methods that you can create in Ruby…an “instance” or a “class” method. In this post I am going to talk a little bit about an “instance” method.
- First lets take a look at what one looks like…

- Above we have our very first method! Methods in Ruby always start with “def” which stands for “definition” and they are over when you see “end”.
- Right after “def” you will see the method’s name. Here the method’s name is “music”.
- What is in those parentheses? Those are known as “arguments” to the method. Let’s take a look at how to put those arguments to work:
- We added a few things…
- Inside of our method we have “puts” followed by what we would like to see printed to the screen in quotation marks.
- Then inside the quotation marks we see #{style} and #{band}. Those are the names of our arguments!!
- The last thing that we see is “music(“The Strokes”, “rock”)”. This is how we call the method. We want to do something to our method so we need to call it and tell it what to do.
- “The Strokes” is going to be replacing the word “band” and “rock” is going to replace the word “style” inside of our method.
- When we run our method you would see the following printed to the screen…

- Awesome! We see the two sentences printed out to the screen! Where we saw #{band} and #{style} have been replace with “The Strokes” and “rock”.
Since I really do love The Strokes here is my favorite song by them…”Last Nite”!
