Learning a new programming language historically starts off with the classic “Hello World” example. I've probably written a variation on that a bazillion times. From there you take more steps into advanced parts of the language. If you are smart, you save your example programs to refer back to them later. But there's a better way. And that better way is to write test cases that exercise the capabilities of the language you are trying to learn. This also works for new libraries within a language you are trying to learn.
The advantages of writing test cases are plentiful. It gets you writing
actual code which helps you remember, they can be usually be run easily,
they serve as an extra source of documentation about what you are trying
to do (e.g. “How do I use
gsub again? Oh yeah, it's in that string
test I wrote?”) and finally writing tests is fun.
(I know it's very simple but I just wanted to get a feel for the first method in the global library and type it so my brain remembered it.)
So, now I drop the test file into my test runner and here we have the results:
Can't you just feel your brain expanding with the possibilities?