Conditional Expressions and Statements : 01/20/2023
Operations on Variables : 01/19/2023
Variables and Types : 01/18/2023
Welcome to CS 124 : 01/17/2023
Introduction to Objects
val example = Example(0)
example.value = 10
A new era begins in CS 124.
We leave the familiar world of basic types and Strings behind and strike out to new horizons.
This lesson begins our discussion of Kotlin objects.
Objects represent both a significant conceptual step forward, and dramatically improve our ability to work with data.
A class definines how an entire group of objects behaves.
For example, we might say that a person is a class of things where each has a name and an age.
Let’s look at our first class definition together:
To create a new instance of a class we use the classes name in a way that
looks like a method call:
// Assignment of a new Example instance to the variable e, setting value to 8 initially
For now the syntax of instance creation will seem somewhat mysterious.
Why does it look like a function call?
That will make more sense soon.
But for now simply follow this template to create new class instances.