Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
String Documentation2:04 with Jason Seifer
The Ruby standard library documentation is a great resource for learning about different parts of Ruby that we can use while writing our programs. In this video, we'll learn how to refer to the documentation when coding.
Methods that are named with an exclamation point at the end generally will change the variable value rather than return a new variable.
Reading the documentation allows you to look up new methods you may not have seen before and reveals how methods work as well as what they return.
Try looking up different methods in the String documentation and using them in your own programs or in IRB.
Now that we've learned how to call some fun methods on strings,
you might be wondering where I got those methods.
I got those from the Ruby documentation.
Let's go ahead and take a look at the documentation and
see how it works and how we can use that in our programs.
There will be a link right below this video that you can click on to see all
of the different things that you can do with strings.
The list of all of the different methods is right here.
We've used the capitalize method, the downcase method,
And the upcase method.
Now, you'll notice if we click on upcase, it returns a new string.
The documentation says that this method returns
this particular thing, which returns a copy of string.
You'll notice there is another method here called upcase with an exclamation point.
This isn't Ruby yelling at us.
When we see a method that ends with an exclamation point,
it generally means that the variable was changed.
Let's go ahead and try that now.
I could say name.
And we can see that Ruby is returning my name down here.
If I type name.upcase,
it returns an uppercase version of my name.
But, with the exclamation point,
the original name variable has also been modified.
Go ahead and try different things in the IRB console.
If you get stuck, you can also play around with some of the documentation here and
see what these different methods do on strings.
You need to sign up for Treehouse in order to download course files.Sign up