Code Editor
Learn
Object-Oriented Programming I

Classes Are Serious Business

Classes like Language and Person are great when you are starting to learn the concepts of classes and instances.

However, classes and objects are often used to model real-world objects. The code in the editor is a more realistic demonstration of the kind of classes and objects you might find in commercial software. Here we have a snippet of the Rails source code. See how they've created an instance of the RecordInvalid class?

Instructions

Most of the syntax should look familiar to you; the raise bit (which we'll cover in future lessons) generates a new RecordInvalid error if the user tries to create or save an invalid record.

Click Run to continue!

Report a Bug
If you see a bug or any other issue with this page, please report it here.